Merge output data from multiple batches, select metabolite columns, add participant info and other data
acg_batch1 <- read.csv("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/ACG_LCM_CorrectedTable_12-14-2021-16-15.csv")
acg_batch2 <- read.csv("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/ACG_LCM_CorrectedTable_12-14-2021-16-21.csv")
acg_LCM_corr <- bind_rows(acg_batch1, acg_batch2)
anyDuplicated(acg_LCM_corr$File_ID) #check for duplicated values
## [1] 106
acg_LCM_corr<-unique(acg_LCM_corr) #remove duplicate rows
acg_LCM_corr["4", "Cho_GPC_PCh_conc_molar"]<-NA #Cho conc invalid for PS10008_PS14_046_2386 due to spike in spectrum
acg_LCM_corr["4", "Cho_GPC_PCh_conc_molal"]<-NA #Cho conc invalid for PS10008_PS14_046_2386 due to spike in spectrum
write.csv(acg_LCM_corr, "/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/ACG_LCM_CorrectedTable_19-01-2021_all.csv", row.names = FALSE)
acg_molal <- acg_LCM_corr %>%
dplyr::select(File_ID, fGM, fWM, fCSF, NAA_conc_molal, Cre_PCr_conc_molal, Cho_GPC_PCh_conc_molal, Ins_conc_molal, Glu_conc_molal, Glu_Gln_conc_molal)
acg_demo <- read.csv("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/acg_analysis_subs.csv")
acg_dat <- left_join(acg_demo, acg_molal, by = "File_ID")
#convert subj_id variable to "character" type for later merging
acg_dat$subj_id <- as.character(acg_dat$subj_id)
write.csv(acg_dat, "/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/acg_data_molal_n114_usethisone.csv", row.names = FALSE)
lag_batch1 <- read.csv("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/LAG_LCM_CorrectedTable_12-13-2021-15-18.csv")
lag_batch2 <- read.csv("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/LAG_LCM_CorrectedTable_12-14-2021-11-41.csv")
lag_batch3 <- read.csv("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/LAG_LCM_CorrectedTable_12-14-2021-12-18.csv")
lag_LCM_corr <- bind_rows(lag_batch1, lag_batch2, lag_batch3)
write.csv(lag_LCM_corr, "/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/LAG_LCM_CorrectedTable_19-01-2022_all.csv", row.names = FALSE)
lag_molal <- lag_LCM_corr %>%
dplyr::select(File_ID, fGM, fWM, fCSF, NAA_conc_molal, Cre_PCr_conc_molal, Cho_GPC_PCh_conc_molal, Ins_conc_molal, Glu_conc_molal, Glu_Gln_conc_molal)
lag_demo <- read.csv("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/lag_analysis_subs.csv")
lag_dat <- left_join(lag_demo, lag_molal, by = "File_ID")
lag_dat$subj_id<-as.character(lag_dat$subj_id) #make subj_id character type
write.csv(lag_dat, "/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/lag_data_molal_n320_usethisone.csv", row.names = FALSE)
##Check data distribution & outliers Create plots to check data distribution and identify outliers
ACG
plot_age <- ggplot(acg_dat, aes(mri_age_y))
plot_age + geom_density()
#age skewed (expected given study design, accounting for repeated measures in lmer)
plot_naa <- ggplot(acg_dat, aes(NAA_conc_molal))
plot_naa + geom_density()
plot_naa + geom_boxplot()
rosnerTest(acg_dat$NAA_conc_molal, k = 4)
## $distribution
## [1] "Normal"
##
## $statistic
## R.1 R.2 R.3 R.4
## 2.766723 2.832798 2.682199 2.728017
##
## $sample.size
## [1] 114
##
## $parameters
## k
## 4
##
## $alpha
## [1] 0.05
##
## $crit.value
## lambda.1 lambda.2 lambda.3 lambda.4
## 3.428193 3.425263 3.422302 3.419309
##
## $n.outliers
## [1] 0
##
## $alternative
## [1] "Up to 4 observations are not\n from the same Distribution."
##
## $method
## [1] "Rosner's Test for Outliers"
##
## $data
## [1] 13.36240 15.05227 14.57780 13.83339 14.71206 16.20111 15.44740 16.98446
## [9] 15.67072 15.95324 14.87793 12.74216 16.29728 14.71133 14.66048 13.28760
## [17] 14.59532 13.55773 16.85293 15.33699 12.45017 15.04043 15.27049 11.24177
## [25] 14.98401 14.18774 15.83415 13.91788 17.10858 12.09629 14.70242 14.40906
## [33] 16.46456 15.58993 15.03289 14.84971 11.30097 13.87568 15.24533 15.99486
## [41] 14.53574 12.16795 14.20751 14.18561 16.47436 14.52629 15.00648 16.20561
## [49] 13.22605 13.57437 14.05939 13.81423 17.33147 16.31303 16.29984 16.85100
## [57] 15.24641 14.93994 15.14031 15.13625 18.29604 13.89531 13.42919 15.16179
## [65] 13.87656 15.48760 12.64660 16.01636 13.64857 16.43270 15.59565 11.64927
## [73] 15.46789 14.18371 12.72496 16.73666 16.33378 15.15593 15.86369 15.28939
## [81] 15.31529 14.67805 13.38081 15.01442 13.01089 17.11696 14.54570 15.04389
## [89] 14.64002 15.57552 15.21758 15.80866 15.16132 14.92979 14.18939 16.96225
## [97] 13.86479 15.05179 15.22074 15.65731 15.51013 14.39392 15.03669 16.39137
## [105] 14.47850 14.65614 15.94476 16.78988 16.07591 13.54665 13.48426 14.73463
## [113] 15.68117 16.31675
##
## $data.name
## [1] "acg_dat$NAA_conc_molal"
##
## $bad.obs
## [1] 0
##
## $all.stats
## i Mean.i SD.i Value Obs.Num R.i+1 lambda.i+1 Outlier
## 1 0 14.90238 1.323083 11.24177 24 2.766723 3.428193 FALSE
## 2 1 14.93477 1.282761 11.30097 37 2.832798 3.425263 FALSE
## 3 2 14.96722 1.241080 18.29604 61 2.682199 3.422302 FALSE
## 4 3 14.93723 1.205254 11.64927 72 2.728017 3.419309 FALSE
##
## attr(,"class")
## [1] "gofOutlier"
plot_cre <- ggplot(acg_dat, aes(Cre_PCr_conc_molal))
plot_cre + geom_density()
plot_cre + geom_boxplot()
rosnerTest(acg_dat$Cre_PCr_conc_molal, k = 5)
## $distribution
## [1] "Normal"
##
## $statistic
## R.1 R.2 R.3 R.4 R.5
## 3.408436 2.844950 2.721131 2.589170 2.660065
##
## $sample.size
## [1] 114
##
## $parameters
## k
## 5
##
## $alpha
## [1] 0.05
##
## $crit.value
## lambda.1 lambda.2 lambda.3 lambda.4 lambda.5
## 3.428193 3.425263 3.422302 3.419309 3.416284
##
## $n.outliers
## [1] 0
##
## $alternative
## [1] "Up to 5 observations are not\n from the same Distribution."
##
## $method
## [1] "Rosner's Test for Outliers"
##
## $data
## [1] 10.869437 10.445542 14.138594 11.979460 11.842544 12.567296 12.183610
## [8] 13.315617 13.532807 13.910100 12.102060 9.609688 12.566391 11.689508
## [15] 12.650725 10.976876 11.888348 11.823341 12.975541 12.087174 10.745566
## [22] 12.005758 13.958950 11.012768 13.437536 12.359373 12.418194 10.775703
## [29] 13.584172 11.251205 11.993304 12.190118 14.756858 13.780875 12.273252
## [36] 11.243397 8.406874 11.279114 11.602557 13.761404 12.044563 10.276615
## [43] 10.918920 10.896575 11.867174 12.189638 12.580644 12.364280 11.517322
## [50] 10.442494 11.903800 12.566843 12.411654 12.733123 12.852863 14.066514
## [57] 10.742053 11.977272 12.534036 12.467809 13.778825 11.508522 11.740032
## [64] 11.569008 10.891687 12.474281 11.395342 12.716648 12.033736 13.646045
## [71] 12.873670 9.632426 11.901341 12.610355 9.187364 13.087309 12.160354
## [78] 11.717870 12.392428 11.411606 12.417766 11.214681 11.894967 11.689931
## [85] 11.069854 13.648131 12.837410 11.764882 12.329981 11.666319 12.825568
## [92] 13.032058 12.630243 12.355787 11.038718 9.731136 12.044142 11.736949
## [99] 11.772225 11.427900 12.588592 11.074387 11.520514 12.986814 12.563423
## [106] 12.334515 13.095183 12.401466 11.143206 11.414014 11.499070 12.331493
## [113] 11.900989 11.934339
##
## $data.name
## [1] "acg_dat$Cre_PCr_conc_molal"
##
## $bad.obs
## [1] 0
##
## $all.stats
## i Mean.i SD.i Value Obs.Num R.i+1 lambda.i+1 Outlier
## 1 0 12.03501 1.0644580 8.406874 37 3.408436 3.428193 FALSE
## 2 1 12.06712 1.0122338 9.187364 75 2.844950 3.425263 FALSE
## 3 2 12.09283 0.9790145 14.756858 33 2.721131 3.422302 FALSE
## 4 3 12.06883 0.9497805 9.609688 12 2.589170 3.419309 FALSE
## 5 4 12.09119 0.9243235 9.632426 72 2.660065 3.416284 FALSE
##
## attr(,"class")
## [1] "gofOutlier"
plot_cho <- ggplot(acg_dat, aes(Cho_GPC_PCh_conc_molal))
plot_cho + geom_density()
## Warning: Removed 1 rows containing non-finite values (stat_density).
plot_cho + geom_boxplot()
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).
rosnerTest(acg_dat$Cho_GPC_PCh_conc_molal, k = 4)
## Warning in rosnerTest(acg_dat$Cho_GPC_PCh_conc_molal, k = 4): 1 observations
## with NA/NaN/Inf in 'x' removed.
## $distribution
## [1] "Normal"
##
## $statistic
## R.1 R.2 R.3 R.4
## 2.701721 2.499089 2.555664 2.600765
##
## $sample.size
## [1] 113
##
## $parameters
## k
## 4
##
## $alpha
## [1] 0.05
##
## $crit.value
## lambda.1 lambda.2 lambda.3 lambda.4
## 3.425263 3.422302 3.419309 3.416284
##
## $n.outliers
## [1] 0
##
## $alternative
## [1] "Up to 4 observations are not\n from the same Distribution."
##
## $method
## [1] "Rosner's Test for Outliers"
##
## $data
## [1] 3.054728 2.338141 2.483788 2.615586 2.904744 3.029351 2.945605 2.946224
## [9] 2.469310 2.647417 2.329234 2.525650 2.964839 2.377024 2.316960 2.388015
## [17] 2.587590 2.964150 2.987201 1.884924 2.294818 2.160623 1.723047 2.273437
## [25] 2.486538 2.364455 2.110030 3.042283 2.145223 2.626855 2.657139 3.307897
## [33] 2.993478 2.528009 2.694001 2.751861 2.169544 2.576529 2.777803 2.298135
## [41] 2.093485 2.245856 1.887058 3.332061 2.683945 2.960541 2.306091 2.400287
## [49] 2.262987 2.373107 2.418340 2.428692 2.651362 2.724707 2.627568 3.213338
## [57] 2.541659 2.436647 2.503022 3.168533 2.273151 2.230455 2.575725 2.463493
## [65] 2.964749 2.427496 2.382196 2.398624 2.592440 2.075228 1.967159 2.210616
## [73] 2.178031 1.572637 2.265866 2.193475 2.435427 2.749229 2.738993 2.096637
## [81] 2.376787 2.150157 2.031053 1.736687 2.549619 2.032952 2.153716 2.354125
## [89] 2.585598 2.624180 2.597158 2.503254 2.679817 2.109408 2.755517 2.618999
## [97] 2.254582 2.379855 2.105926 2.389925 2.621861 2.349337 2.962557 2.620008
## [105] 2.643999 2.559238 3.322683 2.403398 2.301871 2.505683 2.762249 2.704160
## [113] 2.422916
##
## $data.name
## [1] "acg_dat$Cho_GPC_PCh_conc_molal"
##
## $bad.obs
## [1] 1
##
## $all.stats
## i Mean.i SD.i Value Obs.Num R.i+1 lambda.i+1 Outlier
## 1 0 2.495242 0.3414881 1.572637 75 2.701721 3.425263 FALSE
## 2 1 2.503480 0.3315535 3.332061 45 2.499089 3.422302 FALSE
## 3 2 2.496015 0.3234649 3.322683 108 2.555664 3.419309 FALSE
## 4 3 2.488500 0.3150601 3.307897 33 2.600765 3.416284 FALSE
##
## attr(,"class")
## [1] "gofOutlier"
plot_ins <- ggplot(acg_dat, aes(Ins_conc_molal))
plot_ins + geom_density()
shapiro.test(acg_dat$Ins_conc_molal) #not normal
##
## Shapiro-Wilk normality test
##
## data: acg_dat$Ins_conc_molal
## W = 0.96331, p-value = 0.003248
plot_ins + geom_boxplot()
rosnerTest(acg_dat$Ins_conc_molal, k = 3) #outlier value 1.471244, observation 84 (PS18_013) - spectrum showed issue, exclude from analysis
## $distribution
## [1] "Normal"
##
## $statistic
## R.1 R.2 R.3
## 3.754451 3.041642 3.046236
##
## $sample.size
## [1] 114
##
## $parameters
## k
## 3
##
## $alpha
## [1] 0.05
##
## $crit.value
## lambda.1 lambda.2 lambda.3
## 3.428193 3.425263 3.422302
##
## $n.outliers
## [1] 1
##
## $alternative
## [1] "Up to 3 observations are not\n from the same Distribution."
##
## $method
## [1] "Rosner's Test for Outliers"
##
## $data
## [1] 7.633881 8.178435 7.218240 7.696923 8.696692 8.600324 9.402207
## [8] 8.875539 6.779586 5.935284 10.304907 5.028532 7.058793 9.067489
## [15] 6.700483 7.361395 8.124760 8.682546 6.553380 6.320046 7.315123
## [22] 7.446418 7.281237 7.102747 9.505161 7.839894 7.887706 7.616099
## [29] 7.601724 6.347168 7.912922 5.656884 9.656654 9.672370 8.341248
## [36] 8.816154 5.196891 6.304340 6.789199 8.018694 7.594973 7.416233
## [43] 7.406756 3.198494 2.985922 9.898020 8.079535 8.703354 7.157223
## [50] 6.213808 8.399767 9.174211 9.656691 9.335033 10.080614 4.813291
## [57] 9.728369 7.521052 7.441993 8.051283 10.887902 8.695335 5.872553
## [64] 6.418561 5.242212 8.749670 7.765345 8.185832 7.950928 8.394652
## [71] 9.583041 6.202420 7.829477 6.209769 4.285017 8.677590 7.775045
## [78] 9.334317 8.684385 7.236647 7.742767 6.219638 9.105159 1.471244
## [85] 5.218826 9.407651 7.634559 6.064850 8.785683 3.770173 7.618745
## [92] 8.763466 7.123140 6.399259 6.804541 5.855502 9.364210 6.203701
## [99] 10.565682 9.856594 7.453487 7.728481 7.846516 9.947994 8.640216
## [106] 7.758280 8.476271 8.672477 6.437713 5.739577 6.673856 7.596796
## [113] 7.229168 6.379001
##
## $data.name
## [1] "acg_dat$Ins_conc_molal"
##
## $bad.obs
## [1] 0
##
## $all.stats
## i Mean.i SD.i Value Obs.Num R.i+1 lambda.i+1 Outlier
## 1 0 7.578251 1.626604 1.471244 84 3.754451 3.428193 TRUE
## 2 1 7.632295 1.527587 2.985922 45 3.041642 3.425263 FALSE
## 3 2 7.673781 1.469121 3.198494 44 3.046236 3.422302 FALSE
##
## attr(,"class")
## [1] "gofOutlier"
acg_dat["84", "Ins_conc_molal"] <- NA #replace outlier value with NA to exclude from analysis
plot_glx <- ggplot(acg_dat, aes(Glu_Gln_conc_molal))
plot_glx + geom_density()
plot_glx + geom_boxplot()
rosnerTest(acg_dat$Glu_Gln_conc_molal, k = 1)
## $distribution
## [1] "Normal"
##
## $statistic
## R.1
## 2.841812
##
## $sample.size
## [1] 114
##
## $parameters
## k
## 1
##
## $alpha
## [1] 0.05
##
## $crit.value
## lambda.1
## 3.428193
##
## $n.outliers
## [1] 0
##
## $alternative
## [1] "Up to 1 observations are not\n from the same Distribution."
##
## $method
## [1] "Rosner's Test for Outliers"
##
## $data
## [1] 22.16208 24.54895 30.79902 25.15445 23.12144 23.45996 27.95219 28.85494
## [9] 28.47293 30.83024 24.02170 20.83895 26.81225 25.81936 25.83210 28.15351
## [17] 28.69984 24.45281 25.87441 26.10568 24.90431 27.69072 29.16664 25.73952
## [25] 31.00567 25.29233 29.35298 28.81394 30.45098 26.42377 25.25458 30.67838
## [33] 29.65833 34.25604 26.24353 28.06087 21.93668 25.00839 27.05607 29.92424
## [41] 27.12366 23.65348 26.82576 24.86136 26.92752 23.98651 26.21693 28.06806
## [49] 26.26637 27.44238 23.98526 25.40089 22.59948 23.46421 28.23542 33.70878
## [57] 26.99835 25.59893 26.95525 25.77541 32.34599 24.66776 25.46001 25.71687
## [65] 29.73266 25.54233 27.95401 29.18637 26.09421 27.74434 27.70571 21.88957
## [73] 26.72328 30.44184 21.32831 31.44932 28.73199 25.08766 29.57015 24.10930
## [81] 27.84161 24.85586 29.21009 20.93551 23.34771 27.38610 26.35670 26.10330
## [89] 28.90132 26.67329 24.94565 29.44010 29.32746 26.23233 24.32566 24.39736
## [97] 26.88103 30.91320 28.56651 27.47953 25.89977 24.22166 25.89081 28.12079
## [105] 29.77257 28.04112 29.21096 29.61668 27.08694 28.10033 24.05989 26.66364
## [113] 26.45077 28.51150
##
## $data.name
## [1] "acg_dat$Glu_Gln_conc_molal"
##
## $bad.obs
## [1] 0
##
## $all.stats
## i Mean.i SD.i Value Obs.Num R.i+1 lambda.i+1 Outlier
## 1 0 26.84411 2.608172 34.25604 34 2.841812 3.428193 FALSE
##
## attr(,"class")
## [1] "gofOutlier"
write.csv(acg_dat, "/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/acg_data_molal_outliers_removed_n114.csv", row.names = FALSE)
LAG
plot_age <- ggplot(lag_dat, aes(mri_age_y))
plot_age + geom_density()
#age skewed, we're accounting for repeated measures with lmer
plot_naa <- ggplot(lag_dat, aes(NAA_conc_molal))
plot_naa + geom_density()
plot_naa + geom_boxplot()
rosnerTest(lag_dat$NAA_conc_molal, k = 10) #outliers val. 19.207, obs. 296 & Val. 10.148, obs. 306 - some issues in spectra, exclude from analysis for NAA
## $distribution
## [1] "Normal"
##
## $statistic
## R.1 R.2 R.3 R.4 R.5 R.6 R.7 R.8
## 4.488107 4.054220 3.620474 3.636006 3.047967 2.727339 2.666576 2.672228
## R.9 R.10
## 2.668103 2.683754
##
## $sample.size
## [1] 320
##
## $parameters
## k
## 10
##
## $alpha
## [1] 0.05
##
## $crit.value
## lambda.1 lambda.2 lambda.3 lambda.4 lambda.5 lambda.6 lambda.7 lambda.8
## 3.741706 3.740829 3.739949 3.739067 3.738181 3.737291 3.736399 3.735503
## lambda.9 lambda.10
## 3.734604 3.733702
##
## $n.outliers
## [1] 2
##
## $alternative
## [1] "Up to 10 observations are not\n from the same Distribution."
##
## $method
## [1] "Rosner's Test for Outliers"
##
## $data
## [1] 14.16473 13.06076 14.35969 13.27563 16.92063 13.92045 14.90883 14.96705
## [9] 13.87538 13.79928 15.43119 13.74363 13.42774 14.32941 15.29816 15.36852
## [17] 14.96343 14.01462 15.11779 16.29892 15.28430 15.17137 15.34158 15.28575
## [25] 13.61378 16.76759 13.63702 14.41263 13.69061 15.64950 14.60942 15.25717
## [33] 15.68290 14.24180 15.96102 13.19084 14.22355 14.45688 13.89590 16.68967
## [41] 15.14115 13.88211 14.56337 14.77687 14.00542 14.12098 13.36743 13.70315
## [49] 14.59050 15.55276 13.33791 14.13365 12.08635 14.08027 13.90090 13.63249
## [57] 15.72428 11.86871 14.17563 11.96658 12.37485 14.57472 13.54554 14.35760
## [65] 13.86325 16.89273 14.68644 16.67785 15.93255 16.85334 14.93659 14.21829
## [73] 13.99673 14.23697 13.86957 13.86406 14.36716 14.41372 12.45632 14.76312
## [81] 14.75832 14.92673 13.88514 14.24089 15.42366 14.86462 14.32717 14.96667
## [89] 13.72426 14.16948 15.16894 13.93828 12.92563 13.94977 13.64160 14.55102
## [97] 14.51660 12.52392 14.21054 13.93670 16.19979 14.45536 14.10612 13.35969
## [105] 16.58862 14.41649 14.80811 14.26277 12.37256 15.44893 13.43728 13.57859
## [113] 13.72929 14.86513 11.95501 14.39891 14.11323 14.14168 14.73091 14.40429
## [121] 13.19741 13.71443 14.26528 14.92876 14.67063 14.35362 15.12298 13.95432
## [129] 13.68703 13.44733 14.01869 14.75568 14.74986 11.38458 12.08162 11.74260
## [137] 13.93366 14.16181 14.38636 14.40623 14.15278 14.17590 15.46643 14.09616
## [145] 13.62893 14.14878 13.54441 13.09883 12.79401 14.64345 14.02714 14.59131
## [153] 14.51512 15.41640 13.41648 13.54853 13.78080 13.79989 13.51420 14.77851
## [161] 15.60295 13.13390 13.99763 14.27699 15.00866 15.01634 12.09852 14.98452
## [169] 13.60870 16.34165 11.91384 12.33377 14.09992 15.06924 13.87378 13.47019
## [177] 14.02295 18.06089 14.25601 14.37746 13.24330 15.14502 13.95585 13.43714
## [185] 14.30145 16.30323 13.44700 14.70962 13.78765 13.43206 14.86922 14.73623
## [193] 14.54106 13.30455 14.61897 13.91250 15.44818 13.00756 14.21959 16.58017
## [201] 14.30707 15.14338 12.83493 13.96649 15.41109 13.77502 12.24289 15.19071
## [209] 13.32940 13.11120 15.00722 15.15742 13.96143 14.70099 14.27321 15.14983
## [217] 14.79365 15.19557 14.84745 13.19832 15.12751 13.95088 13.28456 14.90679
## [225] 12.94820 13.28282 14.39416 13.76430 14.91352 15.55618 15.20787 14.89958
## [233] 14.31622 14.53646 15.29391 13.51980 15.05685 14.73951 15.01094 15.61748
## [241] 14.09588 14.63147 15.59956 15.33848 14.07436 14.30913 13.94217 16.47833
## [249] 15.29907 13.85813 15.73137 15.08295 16.15169 14.28221 15.30824 14.47596
## [257] 14.47137 14.28477 15.33016 14.75400 14.54703 14.66072 13.49926 14.47973
## [265] 13.83620 14.83537 15.05792 14.18100 13.68113 13.28288 14.53224 13.92267
## [273] 14.80805 13.25470 14.60733 13.77756 15.36693 16.13917 14.36568 14.54767
## [281] 14.51644 16.31083 15.95003 13.41067 15.50889 13.79439 14.53462 14.83200
## [289] 14.42306 13.93431 13.79584 14.91428 12.66542 14.98849 15.38162 19.20747
## [297] 13.74790 17.99338 14.95991 13.93438 15.42154 13.27326 13.14415 14.47594
## [305] 13.99067 10.14812 13.73230 14.91913 15.85376 13.23125 13.40927 14.90803
## [313] 14.30314 14.54287 14.33013 16.55184 14.94880 14.30460 15.31501 14.46473
##
## $data.name
## [1] "lag_dat$NAA_conc_molal"
##
## $bad.obs
## [1] 0
##
## $all.stats
## i Mean.i SD.i Value Obs.Num R.i+1 lambda.i+1 Outlier
## 1 0 14.38548 1.0743933 19.20747 296 4.488107 3.741706 TRUE
## 2 1 14.37036 1.0414430 10.14812 306 4.054220 3.740829 TRUE
## 3 2 14.38364 1.0156823 18.06089 178 3.620474 3.739949 FALSE
## 4 3 14.37204 0.9959661 17.99338 298 3.636006 3.739067 FALSE
## 5 4 14.36058 0.9763881 11.38458 134 3.047967 3.738181 FALSE
## 6 5 14.37003 0.9633663 11.74260 136 2.727339 3.737291 FALSE
## 7 6 14.37839 0.9533698 16.92063 5 2.666576 3.736399 FALSE
## 8 7 14.37027 0.9439526 16.89273 66 2.672228 3.735503 FALSE
## 9 8 14.36219 0.9345517 11.86871 58 2.668103 3.734604 FALSE
## 10 9 14.37020 0.9252478 16.85334 70 2.683754 3.733702 FALSE
##
## attr(,"class")
## [1] "gofOutlier"
lag_dat["296", "NAA_conc_molal"]<- NA
lag_dat["306", "NAA_conc_molal"]<- NA
plot_cre <- ggplot(lag_dat, aes(Cre_PCr_conc_molal))
plot_cre + geom_density()
plot_cre + geom_boxplot()
rosnerTest(lag_dat$Cre_PCr_conc_molal, k = 10) #outliers val. 14.829, obs. 241 (PS17_047) - structure in resid. & val. 14.09, obs. 178 (PS17_045, spectrum looked fine), excluding only PS17_047 for now
## $distribution
## [1] "Normal"
##
## $statistic
## R.1 R.2 R.3 R.4 R.5 R.6 R.7 R.8
## 4.857819 4.242800 3.340731 3.299490 3.295540 3.317618 2.919413 2.903784
## R.9 R.10
## 2.788513 2.797440
##
## $sample.size
## [1] 320
##
## $parameters
## k
## 10
##
## $alpha
## [1] 0.05
##
## $crit.value
## lambda.1 lambda.2 lambda.3 lambda.4 lambda.5 lambda.6 lambda.7 lambda.8
## 3.741706 3.740829 3.739949 3.739067 3.738181 3.737291 3.736399 3.735503
## lambda.9 lambda.10
## 3.734604 3.733702
##
## $n.outliers
## [1] 2
##
## $alternative
## [1] "Up to 10 observations are not\n from the same Distribution."
##
## $method
## [1] "Rosner's Test for Outliers"
##
## $data
## [1] 9.979902 8.752796 9.874363 8.961297 11.510180 10.121568 10.418593
## [8] 11.028922 10.171413 9.929791 10.871830 11.064228 10.111309 9.319128
## [15] 10.662947 10.890644 10.197139 9.919287 10.426231 11.325982 10.557574
## [22] 11.088082 11.039646 11.172931 8.936929 12.109674 10.000368 10.420059
## [29] 9.572731 10.511121 9.984628 10.695378 11.039338 9.822119 11.097416
## [36] 9.239262 9.742404 10.192047 10.845538 12.117826 10.389433 9.535353
## [43] 10.010295 10.823639 9.876324 10.019161 8.608303 9.442680 11.444015
## [50] 11.419644 9.408142 10.139106 8.483950 9.792171 10.032519 8.968350
## [57] 11.562417 9.156420 10.285179 7.449145 10.159106 10.623228 10.245682
## [64] 11.514351 10.182653 11.786704 11.560836 12.034078 11.166365 11.463697
## [71] 10.397742 10.176308 11.796639 10.733740 10.174742 10.465407 9.824296
## [78] 11.420357 7.832529 10.284534 12.513826 11.576531 10.541650 10.808215
## [85] 10.483803 10.041962 10.382300 9.976776 10.765842 10.520082 11.422196
## [92] 10.843472 9.968723 10.781936 9.841352 9.930816 11.494602 9.908886
## [99] 10.765624 10.122441 11.914466 10.403873 10.056177 9.179081 11.252406
## [106] 10.011672 10.666794 9.981113 9.225683 10.367639 10.879950 11.335061
## [113] 9.425501 10.725975 10.241112 9.317008 9.889557 9.560765 10.593153
## [120] 11.263291 8.935236 10.137273 10.048855 11.211108 10.481657 10.028783
## [127] 11.460008 9.844337 10.207849 8.876822 9.557376 9.418484 9.631575
## [134] 11.004550 7.414051 8.984416 9.798072 10.236338 10.150536 10.108983
## [141] 10.653763 10.137920 10.541536 9.525275 9.886573 9.896683 9.185657
## [148] 9.642602 7.281217 9.968306 10.715037 10.739283 11.039381 11.250002
## [155] 9.759444 9.643949 9.675426 9.621214 9.141950 10.356422 10.788507
## [162] 9.362209 9.822128 9.645301 10.157630 10.381588 8.913720 11.109833
## [169] 9.890247 12.488886 9.115647 9.814255 10.627685 11.734993 10.295594
## [176] 10.173568 9.988731 14.090723 10.829617 10.247883 10.533434 10.999808
## [183] 10.001382 9.229915 10.354994 11.296388 9.994843 10.904378 9.345731
## [190] 9.618365 9.759703 10.530182 10.844392 8.895843 10.110129 11.423088
## [197] 11.096328 9.958072 9.931007 10.921273 9.154313 10.482202 10.423407
## [204] 10.629254 12.212044 9.913344 8.305599 10.446897 9.841379 9.379922
## [211] 9.844787 10.968766 10.801476 9.891839 10.632212 9.671280 10.872873
## [218] 10.666877 10.645958 9.493899 13.103099 9.512697 10.276565 9.846960
## [225] 9.773848 9.929345 11.034653 10.095542 10.422810 10.640722 10.407355
## [232] 11.450386 10.284795 10.179735 11.263605 10.183927 10.257883 10.937157
## [239] 10.529431 11.012918 14.829071 9.133491 11.531961 10.173887 9.610385
## [246] 9.349643 9.324653 10.926724 11.044735 8.859819 11.228731 10.816240
## [253] 11.271292 9.861827 10.852278 10.764773 9.380198 9.481786 10.781017
## [260] 8.985104 9.888393 9.434081 8.870117 9.122209 9.542512 9.889146
## [267] 10.769356 9.616033 8.966342 9.255494 10.764599 9.897261 9.427714
## [274] 8.163350 10.017130 9.265501 10.944724 12.004282 9.764853 9.856451
## [281] 10.020483 12.009948 10.044769 9.667192 11.197137 9.964094 10.035066
## [288] 10.812708 9.728669 9.918824 8.843802 10.202045 9.183452 9.822267
## [295] 10.790509 12.454846 8.641534 9.507122 10.361671 9.646740 11.011202
## [302] 9.075410 10.166484 9.737467 9.615290 7.882414 10.377305 10.224366
## [309] 12.449600 10.083783 9.260131 11.009901 9.914846 9.659798 10.610323
## [316] 11.561746 11.077058 9.291690 10.160005 9.934510
##
## $data.name
## [1] "lag_dat$Cre_PCr_conc_molal"
##
## $bad.obs
## [1] 0
##
## $all.stats
## i Mean.i SD.i Value Obs.Num R.i+1 lambda.i+1 Outlier
## 1 0 10.25583 0.9414196 14.829071 241 4.857819 3.741706 TRUE
## 2 1 10.24149 0.9072390 14.090723 178 4.242800 3.740829 TRUE
## 3 2 10.22939 0.8824919 7.281217 149 3.340731 3.739949 FALSE
## 4 3 10.23869 0.8681385 13.103099 221 3.299490 3.739067 FALSE
## 5 4 10.22962 0.8543578 7.414051 135 3.295540 3.738181 FALSE
## 6 5 10.23856 0.8407884 7.449145 60 3.317618 3.737291 FALSE
## 7 6 10.24744 0.8271914 7.832529 79 2.919413 3.736399 FALSE
## 8 7 10.25516 0.8171214 7.882414 306 2.903784 3.735503 FALSE
## 9 8 10.26276 0.8072630 12.513826 81 2.788513 3.734604 FALSE
## 10 9 10.25552 0.7983590 12.488886 170 2.797440 3.733702 FALSE
##
## attr(,"class")
## [1] "gofOutlier"
lag_dat["241", "Cre_PCr_conc_molal"]<-NA #replace outlier value with NA to exclude from analysis
plot_cho <- ggplot(lag_dat, aes(Cho_GPC_PCh_conc_molal))
plot_cho + geom_density()
plot_cho + geom_boxplot()
rosnerTest(lag_dat$Cho_GPC_PCh_conc_molal, k = 8)
## $distribution
## [1] "Normal"
##
## $statistic
## R.1 R.2 R.3 R.4 R.5 R.6 R.7 R.8
## 3.695307 3.122621 3.057622 3.063490 2.975253 3.003111 2.867860 2.735173
##
## $sample.size
## [1] 320
##
## $parameters
## k
## 8
##
## $alpha
## [1] 0.05
##
## $crit.value
## lambda.1 lambda.2 lambda.3 lambda.4 lambda.5 lambda.6 lambda.7 lambda.8
## 3.741706 3.740829 3.739949 3.739067 3.738181 3.737291 3.736399 3.735503
##
## $n.outliers
## [1] 0
##
## $alternative
## [1] "Up to 8 observations are not\n from the same Distribution."
##
## $method
## [1] "Rosner's Test for Outliers"
##
## $data
## [1] 2.068181 2.062467 2.386391 2.355035 2.498191 2.256110 2.077815 2.425292
## [9] 2.398770 1.895982 1.865260 2.184158 2.004899 2.128662 2.236830 2.378977
## [17] 2.355458 2.266506 2.404117 2.307009 2.052566 2.364941 2.267604 1.940308
## [25] 2.587651 2.716570 2.469831 2.547177 2.087747 2.170207 2.232363 2.241430
## [33] 2.441839 2.264953 2.333662 2.359801 2.270399 2.241648 1.920730 2.467142
## [41] 2.242001 2.227010 2.229581 2.053798 1.939191 2.364334 2.678152 2.362113
## [49] 1.676867 2.166236 2.306276 2.211050 2.178445 2.361600 2.344510 2.268087
## [57] 2.667157 2.059386 2.034573 2.045022 2.214431 2.995506 1.846508 2.183946
## [65] 2.072392 2.429630 2.330074 2.491408 2.265040 2.154392 2.411001 2.046897
## [73] 2.534412 2.027012 2.376839 2.222266 2.306644 2.292419 2.108096 2.172672
## [81] 1.839589 1.859195 1.443755 1.640698 2.420001 2.337525 2.238790 2.240345
## [89] 2.290795 2.399979 2.350376 2.151479 2.142910 2.110996 1.985190 1.928934
## [97] 2.304258 1.765061 2.137595 1.985591 2.781876 2.123475 1.756957 1.700318
## [105] 1.975316 1.974756 1.999963 2.031005 1.687589 1.708882 2.296279 2.182991
## [113] 2.276755 2.101586 1.837847 2.371711 2.065515 2.499424 2.363551 2.223515
## [121] 2.232809 2.045991 1.947255 2.339091 2.193248 2.528316 2.691920 2.777161
## [129] 2.451074 2.763753 2.377191 2.160428 2.215103 2.214312 2.533792 2.384939
## [137] 2.179386 2.552211 2.673232 2.476304 1.625876 1.926042 2.202001 2.204096
## [145] 2.344069 2.152159 1.895155 1.710908 1.401447 1.946252 2.047116 2.456831
## [153] 2.086612 2.201666 2.190181 2.294616 2.581968 2.225911 2.498999 2.000618
## [161] 2.163682 1.960245 2.204252 2.159811 2.097381 2.254865 1.844443 1.598729
## [169] 1.951488 3.208685 1.836756 1.950559 1.992121 2.281328 2.008449 2.599790
## [177] 2.317712 3.033330 2.698335 2.332814 2.583764 2.234143 2.191218 2.264957
## [185] 1.977277 2.067888 2.356329 2.431505 2.779803 2.150897 2.566469 2.101205
## [193] 2.159059 2.164490 2.152499 2.489624 2.791537 1.673365 2.193421 2.761471
## [201] 1.959300 2.022674 1.970196 2.366537 2.774857 2.129388 1.836375 2.360163
## [209] 2.476086 2.665161 2.258604 2.298965 2.012883 2.201029 2.158646 2.353116
## [217] 1.946114 1.912304 1.692442 2.307008 2.449170 2.132806 2.045527 2.155850
## [225] 2.166616 2.440956 1.783126 2.272129 2.595674 2.284913 2.155251 2.400964
## [233] 2.048543 2.045160 2.356748 2.222524 2.346513 2.378440 2.281038 1.906127
## [241] 1.725583 2.479767 2.262261 2.082256 2.047599 2.138599 2.252565 2.262486
## [249] 1.881557 2.322610 1.489680 2.225178 2.118903 2.390375 2.437536 2.400945
## [257] 1.832693 2.290250 2.007843 2.346441 2.089229 2.428740 2.391081 2.732220
## [265] 1.971298 2.235255 2.116196 1.941129 2.009743 1.999019 1.927678 1.994412
## [273] 2.372282 2.491822 1.886355 2.109659 2.028203 1.807961 2.439615 2.152157
## [281] 1.892138 2.163111 2.376896 1.914835 2.734225 1.944843 1.756721 2.135482
## [289] 2.101386 1.768588 1.974516 1.975407 2.167757 2.112266 2.510332 2.521732
## [297] 2.431779 2.959724 2.046249 1.986009 2.300110 2.368720 2.151772 2.070465
## [305] 2.457353 2.243696 2.105342 2.108232 2.180180 2.349512 1.911659 2.150353
## [313] 2.011103 2.243254 2.417149 1.800195 2.190437 2.875345 2.116343 2.319437
##
## $data.name
## [1] "lag_dat$Cho_GPC_PCh_conc_molal"
##
## $bad.obs
## [1] 0
##
## $all.stats
## i Mean.i SD.i Value Obs.Num R.i+1 lambda.i+1 Outlier
## 1 0 2.207542 0.2709228 3.208685 170 3.695307 3.741706 FALSE
## 2 1 2.204404 0.2654586 3.033330 178 3.122621 3.740829 FALSE
## 3 2 2.201797 0.2617559 1.401447 149 3.057622 3.739949 FALSE
## 4 3 2.204322 0.2582625 2.995506 62 3.063490 3.739067 FALSE
## 5 4 2.201818 0.2547896 1.443755 83 2.975253 3.738181 FALSE
## 6 5 2.204225 0.2515721 2.959724 298 3.003111 3.737291 FALSE
## 7 6 2.201819 0.2483171 1.489680 251 2.867860 3.736399 FALSE
## 8 7 2.204094 0.2454146 2.875345 318 2.735173 3.735503 FALSE
##
## attr(,"class")
## [1] "gofOutlier"
plot_ins <- ggplot(lag_dat, aes(Ins_conc_molal))
plot_ins + geom_density()
plot_ins + geom_boxplot()
rosnerTest(lag_dat$Ins_conc_molal, k = 8) #outliers: val. 14.077, obs. 241 (PS17_047) - structure in resid; val. 11.777, obs. 221 (PS16_014) - spectrum fine, keep for now; val. 1.542, obs. 197 (PS18_028) - noisy spectrum, spiky residuals, exclude; val. 2.04, obs. 62 (PS14_111) - spectrum fine, keep for now
## $distribution
## [1] "Normal"
##
## $statistic
## R.1 R.2 R.3 R.4 R.5 R.6 R.7 R.8
## 5.972077 4.456415 4.071360 3.755604 3.379346 3.298058 3.143191 3.100791
##
## $sample.size
## [1] 320
##
## $parameters
## k
## 8
##
## $alpha
## [1] 0.05
##
## $crit.value
## lambda.1 lambda.2 lambda.3 lambda.4 lambda.5 lambda.6 lambda.7 lambda.8
## 3.741706 3.740829 3.739949 3.739067 3.738181 3.737291 3.736399 3.735503
##
## $n.outliers
## [1] 4
##
## $alternative
## [1] "Up to 8 observations are not\n from the same Distribution."
##
## $method
## [1] "Rosner's Test for Outliers"
##
## $data
## [1] 8.084411 7.069186 6.913031 6.915494 7.726417 8.046174 6.937152
## [8] 4.793633 5.952276 6.984233 6.400936 4.413732 7.176021 7.448535
## [15] 7.547442 6.541306 8.400250 5.957678 6.965664 7.688786 6.245160
## [22] 7.360921 7.925104 4.710055 6.035369 7.937845 7.166536 7.269577
## [29] 5.736145 7.751891 6.217281 7.121735 7.138640 6.104017 7.736566
## [36] 6.539681 4.958196 7.275083 6.485777 6.598573 7.153802 7.352086
## [43] 7.119035 6.146843 6.038556 6.638197 4.629802 6.187281 6.553798
## [50] 5.945866 7.474194 5.559932 5.743412 6.163849 8.347824 4.432658
## [57] 8.169688 5.045280 8.873237 6.213139 6.400722 2.040275 8.158702
## [64] 6.760986 6.468052 7.273556 6.742605 7.552488 7.843304 5.876394
## [71] 8.162408 4.963944 7.945325 5.440451 4.854219 4.834565 5.839066
## [78] 5.839637 5.890621 5.871859 6.963936 5.579543 5.190653 7.062975
## [85] 6.065434 7.046003 6.865074 6.210505 6.024185 6.121049 8.133551
## [92] 6.863480 6.537634 7.457231 5.008241 6.892333 5.936366 3.826364
## [99] 7.075620 5.567096 5.248858 5.491554 4.529573 7.011630 5.896171
## [106] 6.268198 5.292489 5.663161 6.753982 5.643647 6.788746 5.437125
## [113] 3.078293 7.511207 2.568354 8.286250 5.309958 6.053735 8.092627
## [120] 7.122038 6.509101 6.564424 5.780997 6.770400 5.727577 7.829891
## [127] 6.206182 7.258719 6.558572 4.787960 6.132452 6.029208 6.663446
## [134] 7.630692 4.608510 5.731585 5.435869 5.209567 2.734199 5.857696
## [141] 5.638088 6.135153 6.888234 5.236533 5.655180 4.948126 4.992038
## [148] 6.025793 2.972647 6.870427 7.728083 7.800580 7.334580 6.676194
## [155] 6.170230 5.196197 7.073851 6.127912 7.232895 4.960469 6.612268
## [162] 6.088183 5.798318 6.543746 6.997835 6.987522 4.250557 4.637685
## [169] 6.778603 7.502499 4.679992 5.270903 6.367636 6.301188 7.918660
## [176] 6.533953 7.497948 8.801777 6.797100 5.264895 5.014240 6.141243
## [183] 5.472028 3.885218 4.816043 6.248540 4.626087 6.007857 6.538200
## [190] 7.586651 7.411192 7.320786 7.682231 7.120925 6.686811 7.373729
## [197] 1.541994 6.314608 6.840831 7.095049 6.617076 6.056406 5.882616
## [204] 4.775951 5.731427 5.979244 6.418407 6.735628 5.243289 5.869558
## [211] 5.226573 6.275003 7.093997 7.541310 5.731832 4.649731 6.150065
## [218] 6.428658 7.426624 6.729085 11.777066 5.591387 3.080430 8.027587
## [225] 7.066068 6.661947 6.600256 6.955873 6.949031 6.824263 7.605754
## [232] 6.414457 6.094616 6.805794 5.865261 8.270934 4.935241 6.818562
## [239] 5.441384 7.674150 14.076805 4.939637 6.137708 5.300422 6.306576
## [246] 6.245176 7.663984 7.103391 8.335725 3.649002 9.145931 7.122485
## [253] 8.331023 7.199990 8.067478 7.557525 5.521439 6.036198 6.082461
## [260] 7.524328 5.926927 5.705055 5.399996 6.232379 5.707127 4.605042
## [267] 4.333050 5.607343 5.940738 5.740379 6.177392 6.685727 5.210419
## [274] 6.865329 6.749236 5.464544 6.496419 6.705573 7.274507 6.221882
## [281] 5.994352 6.059500 7.660503 6.660801 7.439851 6.777698 5.282780
## [288] 8.773125 6.173129 5.673978 5.639679 5.174471 8.615918 5.774767
## [295] 5.411721 7.832813 7.925781 4.996084 6.276000 6.161567 6.484734
## [302] 5.594141 6.793109 6.401047 9.077790 8.562826 5.674753 6.368745
## [309] 8.425749 6.658481 4.433254 5.482190 7.149805 6.079902 6.139307
## [316] 7.111624 5.971685 6.120964 6.571466 5.418973
##
## $data.name
## [1] "lag_dat$Ins_conc_molal"
##
## $bad.obs
## [1] 0
##
## $all.stats
## i Mean.i SD.i Value Obs.Num R.i+1 lambda.i+1 Outlier
## 1 0 6.383090 1.288281 14.076805 241 5.972077 3.741706 TRUE
## 2 1 6.358972 1.215797 11.777066 221 4.456415 3.740829 TRUE
## 3 2 6.341934 1.178952 1.541994 197 4.071360 3.739949 TRUE
## 4 3 6.357075 1.149429 2.040275 62 3.755604 3.739067 TRUE
## 5 4 6.370736 1.125183 2.568354 115 3.379346 3.738181 FALSE
## 6 5 6.382807 1.106290 2.734199 139 3.298058 3.737291 FALSE
## 7 6 6.394427 1.088632 2.972647 149 3.143191 3.736399 FALSE
## 8 7 6.405359 1.072973 3.078293 113 3.100791 3.735503 FALSE
##
## attr(,"class")
## [1] "gofOutlier"
lag_dat["241", "Ins_conc_molal"] <- NA #replace outlier value with NA to exclude from analysis
lag_dat["197", "Ins_conc_molal"] <- NA
plot_glx <- ggplot(lag_dat, aes(Glu_Gln_conc_molal))
plot_glx + geom_density()
plot_glx + geom_boxplot()
rosnerTest(lag_dat$Glu_Gln_conc_molal, k = 7)#outliers: val. 10.09, obs. 241 (PS17_047) - structure in resid; val. 31.2899, obs. 296 (PS21_030) - big spike in resid. around 2.1, exclude.
## $distribution
## [1] "Normal"
##
## $statistic
## R.1 R.2 R.3 R.4 R.5 R.6 R.7
## 5.004326 4.312337 3.450119 3.484017 3.505727 3.232088 2.666583
##
## $sample.size
## [1] 320
##
## $parameters
## k
## 7
##
## $alpha
## [1] 0.05
##
## $crit.value
## lambda.1 lambda.2 lambda.3 lambda.4 lambda.5 lambda.6 lambda.7
## 3.741706 3.740829 3.739949 3.739067 3.738181 3.737291 3.736399
##
## $n.outliers
## [1] 2
##
## $alternative
## [1] "Up to 7 observations are not\n from the same Distribution."
##
## $method
## [1] "Rosner's Test for Outliers"
##
## $data
## [1] 23.58311 20.72833 21.43465 20.79838 24.55542 19.38008 22.13533 21.98148
## [9] 18.58332 21.80094 23.39061 22.39400 22.25994 19.84839 22.62240 19.74196
## [17] 19.55718 20.18644 20.93614 24.01329 22.14911 23.96545 23.49753 23.68093
## [25] 20.83139 25.55075 18.83744 23.02848 20.10324 24.84118 23.11824 25.62522
## [33] 25.14532 20.60338 23.10183 18.68727 19.90887 22.63726 23.44172 23.97287
## [41] 20.79684 21.03860 21.41871 22.38334 19.07457 19.80466 21.54623 21.54133
## [49] 22.80842 25.04145 20.65555 22.02043 18.52301 21.98565 22.88652 20.99602
## [57] 23.64194 20.45706 24.44658 22.40116 19.22839 24.77315 20.40702 22.32472
## [65] 22.79321 23.27919 23.66026 23.59194 23.28915 23.15967 20.72270 22.14974
## [73] 23.87191 27.09158 23.12072 25.11318 22.08527 21.17324 14.25503 21.44083
## [81] 23.08444 21.47161 23.79592 26.39922 24.52352 23.18206 22.57951 22.53444
## [89] 24.24539 23.38651 21.39081 23.50524 21.84539 23.16617 20.66627 20.68771
## [97] 21.33913 23.82111 24.17549 20.43359 24.17777 21.80255 21.79162 21.34246
## [105] 26.43216 21.02534 21.61161 22.57479 21.58113 22.47585 21.89183 22.86451
## [113] 21.63056 23.83333 23.16833 22.80824 21.74170 19.79860 22.68433 25.43932
## [121] 20.46600 19.55287 21.71921 23.91575 19.94617 22.54020 25.12373 20.26601
## [129] 20.42848 18.40115 22.31740 21.34145 21.18639 24.46723 17.55526 19.17975
## [137] 22.14220 21.22080 20.62138 19.29726 22.33080 22.36491 23.64798 24.04583
## [145] 25.02751 22.02316 20.84404 22.82850 23.75262 19.93399 21.93649 21.46368
## [153] 23.51970 23.79151 22.29261 22.55887 19.88319 23.52534 18.26039 22.44651
## [161] 23.87196 21.33171 21.19221 21.21896 25.13735 21.72890 21.00404 24.38403
## [169] 22.77448 24.07955 20.92792 22.79597 21.53526 25.58587 20.23221 20.38536
## [177] 19.64011 29.12643 21.85437 22.81675 24.27197 20.09271 21.28381 21.20096
## [185] 20.61092 26.55674 20.24095 22.22341 21.17598 21.05662 20.70603 22.17497
## [193] 22.22738 17.77073 21.62541 23.02400 23.16615 17.38515 20.64300 21.97048
## [201] 23.41849 22.42124 20.67899 21.35918 23.92414 18.75710 19.72431 22.35249
## [209] 23.13971 19.66645 21.97753 21.86935 22.15373 18.04793 20.63749 19.81250
## [217] 22.91987 21.99328 21.86022 19.23943 22.18618 21.97414 22.10059 21.96999
## [225] 21.38803 21.08812 21.12026 20.43893 20.01495 22.48505 23.44854 23.27656
## [233] 22.72471 21.03119 22.44160 19.23947 24.24070 21.72010 21.19354 21.24039
## [241] 10.09497 19.32810 23.68178 22.11865 18.91616 19.59606 19.02554 22.92979
## [249] 26.99382 18.91880 22.36158 21.71252 22.51005 20.90044 23.69281 22.60270
## [257] 20.69658 19.00693 19.97580 15.08181 17.70438 17.08767 17.40514 16.78328
## [265] 20.40818 19.57305 21.57031 21.73287 18.10301 16.64465 21.45075 20.54401
## [273] 19.32920 14.36555 21.66594 17.20659 21.57909 24.57946 17.49328 18.35123
## [281] 21.22156 24.11680 22.51873 19.19853 23.08553 19.03798 23.38476 21.59376
## [289] 19.09657 21.28636 18.16122 19.70762 18.41625 18.73419 22.65583 31.28994
## [297] 18.89292 17.32671 18.83142 19.60466 24.66522 18.35557 22.92964 18.49429
## [305] 21.56271 18.98307 20.17174 24.36413 25.12361 21.76663 19.89145 21.01574
## [313] 20.06260 25.41609 26.15708 23.69646 23.29001 20.54746 23.65148 20.44966
##
## $data.name
## [1] "lag_dat$Glu_Gln_conc_molal"
##
## $bad.obs
## [1] 0
##
## $all.stats
## i Mean.i SD.i Value Obs.Num R.i+1 lambda.i+1 Outlier
## 1 0 21.66725 2.312456 10.09497 241 5.004326 3.741706 TRUE
## 2 1 21.70353 2.223021 31.28994 296 4.312337 3.740829 TRUE
## 3 2 21.67338 2.160231 29.12643 178 3.450119 3.739949 FALSE
## 4 3 21.64987 2.122505 14.25503 79 3.484017 3.739067 FALSE
## 5 4 21.67327 2.084509 14.36555 274 3.505727 3.738181 FALSE
## 6 5 21.69647 2.046559 15.08181 260 3.232088 3.737291 FALSE
## 7 6 21.71753 2.015329 27.09158 74 2.666583 3.736399 FALSE
##
## attr(,"class")
## [1] "gofOutlier"
lag_dat["241", "Glu_Gln_conc_molal"] <- NA
lag_dat["296", "Glu_Gln_conc_molal"] <- NA
#exclude PS17_047 from all analyses due to outlier status on multiple metabolites and issues in spectrum (noisy, structure in resid)
lag_dat <- lag_dat[ !(lag_dat$study_code %in% "PS17_047"), ]
write.csv(lag_dat, "/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/lag_data_molal_outliers_removed_n319.csv", row.names = FALSE)
##Descriptive stats
#ACG - count individual subject N and N of females
acg_sub_sex <- acg_dat %>%
dplyr::select(subj_id, female)
acg_unique_subs<-unique(acg_sub_sex)
length(acg_unique_subs$subj_id)
## [1] 103
sum(acg_unique_subs$female)
## [1] 47
describe(acg_dat)
## vars n mean sd median trimmed mad min
## study_code* 1 114 57.50 33.05 57.50 57.50 42.25 1.00
## subj_id* 2 114 51.87 29.16 54.50 51.90 35.58 1.00
## spec_id 3 114 5082.19 3022.83 3284.00 4724.16 1322.48 2058.00
## date_scan* 4 114 49.64 28.95 50.50 49.74 37.81 1.00
## hand* 5 114 4.54 1.03 5.00 4.78 0.00 1.00
## female 6 114 0.46 0.50 0.00 0.46 0.00 0.00
## mri_age_y 7 114 4.07 1.11 3.70 3.99 1.02 2.34
## folder* 8 114 57.50 33.05 57.50 57.50 42.25 1.00
## File_ID* 9 114 57.50 33.05 57.50 57.50 42.25 1.00
## fGM 10 114 0.77 0.05 0.78 0.78 0.05 0.55
## fWM 11 114 0.04 0.03 0.03 0.03 0.02 0.00
## fCSF 12 114 0.19 0.05 0.18 0.19 0.05 0.09
## NAA_conc_molal 13 114 14.90 1.32 15.03 14.96 1.25 11.24
## Cre_PCr_conc_molal 14 114 12.04 1.06 12.04 12.05 0.83 8.41
## Cho_GPC_PCh_conc_molal 15 113 2.50 0.34 2.47 2.49 0.29 1.57
## Ins_conc_molal 16 113 7.63 1.53 7.70 7.70 1.48 2.99
## Glu_conc_molal 17 114 22.38 2.24 22.50 22.47 2.00 16.03
## Glu_Gln_conc_molal 18 114 26.84 2.61 26.77 26.83 2.64 20.84
## max range skew kurtosis se
## study_code* 114.00 113.00 0.00 -1.23 3.10
## subj_id* 103.00 102.00 -0.04 -1.15 2.73
## spec_id 11448.00 9390.00 0.86 -0.80 283.11
## date_scan* 98.00 97.00 -0.04 -1.29 2.71
## hand* 6.00 5.00 -2.08 3.45 0.10
## female 1.00 1.00 0.14 -2.00 0.05
## mri_age_y 7.36 5.03 0.69 -0.57 0.10
## folder* 114.00 113.00 0.00 -1.23 3.10
## File_ID* 114.00 113.00 0.00 -1.23 3.10
## fGM 0.87 0.32 -1.15 1.63 0.01
## fWM 0.29 0.29 4.05 25.16 0.00
## fCSF 0.36 0.27 0.89 0.93 0.00
## NAA_conc_molal 18.30 7.05 -0.39 0.20 0.12
## Cre_PCr_conc_molal 14.76 6.35 -0.36 0.86 0.10
## Cho_GPC_PCh_conc_molal 3.33 1.76 0.17 0.11 0.03
## Ins_conc_molal 10.89 7.90 -0.50 0.33 0.14
## Glu_conc_molal 28.20 12.17 -0.32 0.43 0.21
## Glu_Gln_conc_molal 34.26 13.42 0.12 -0.01 0.24
#re-run descriptives afer excluding 2 subjects for poor coregistration
acg_dat_tf<-read.csv("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/acg_data_molal_outliers_removed_n112_tissuefraction.csv")
#convert subj_id variable to "character" type for later merging
acg_dat_tf$subj_id <- as.character(acg_dat_tf$subj_id)
acg_sub_sex <- acg_dat_tf %>%
dplyr::select(subj_id, female)
acg_unique_subs<-unique(acg_sub_sex)
length(acg_unique_subs$subj_id)
## [1] 101
sum(acg_unique_subs$female)
## [1] 47
describe(acg_dat_tf)
## vars n mean sd median trimmed mad min
## study_code* 1 112 56.50 32.48 56.50 56.50 41.51 1.00
## subj_id* 2 112 50.80 28.57 53.50 50.82 34.84 1.00
## spec_id 3 112 5124.66 3032.78 3342.50 4769.06 1430.71 2058.00
## date_scan* 4 112 48.87 28.71 49.50 48.90 37.81 1.00
## hand* 5 112 4.58 0.98 5.00 4.81 0.00 1.00
## female 6 112 0.47 0.50 0.00 0.47 0.00 0.00
## mri_age_y 7 112 4.09 1.11 3.72 4.01 1.08 2.34
## folder* 8 112 56.50 32.48 56.50 56.50 41.51 1.00
## File_ID* 9 112 56.50 32.48 56.50 56.50 41.51 1.00
## fGM 10 112 0.77 0.05 0.78 0.78 0.04 0.63
## fWM 11 112 0.03 0.02 0.03 0.03 0.02 0.00
## fCSF 12 112 0.19 0.05 0.18 0.19 0.05 0.09
## NAA_conc_molal 13 112 14.97 1.24 15.04 14.99 1.25 11.65
## Cre_PCr_conc_molal 14 112 12.08 1.01 12.04 12.08 0.81 9.19
## Cho_GPC_PCh_conc_molal 15 111 2.50 0.34 2.47 2.49 0.29 1.57
## Ins_conc_molal 16 111 7.66 1.52 7.73 7.73 1.45 2.99
## Glu_conc_molal 17 112 22.45 2.19 22.52 22.52 1.91 16.03
## Glu_Gln_conc_molal 18 112 26.90 2.59 26.82 26.88 2.64 20.84
## TissueFraction_GMWM 19 112 0.96 0.03 0.96 0.96 0.03 0.86
## max range skew kurtosis se
## study_code* 112.00 111.00 0.00 -1.23 3.07
## subj_id* 101.00 100.00 -0.04 -1.14 2.70
## spec_id 11448.00 9390.00 0.83 -0.85 286.57
## date_scan* 97.00 96.00 -0.02 -1.29 2.71
## hand* 6.00 5.00 -2.14 3.77 0.09
## female 1.00 1.00 0.11 -2.01 0.05
## mri_age_y 7.36 5.03 0.66 -0.60 0.11
## folder* 112.00 111.00 0.00 -1.23 3.07
## File_ID* 112.00 111.00 0.00 -1.23 3.07
## fGM 0.87 0.24 -0.85 0.36 0.00
## fWM 0.11 0.11 0.88 1.05 0.00
## fCSF 0.36 0.27 0.87 0.86 0.01
## NAA_conc_molal 18.30 6.65 -0.19 -0.08 0.12
## Cre_PCr_conc_molal 14.76 5.57 -0.12 0.34 0.10
## Cho_GPC_PCh_conc_molal 3.33 1.76 0.24 0.12 0.03
## Ins_conc_molal 10.89 7.90 -0.52 0.41 0.14
## Glu_conc_molal 28.20 12.17 -0.30 0.50 0.21
## Glu_Gln_conc_molal 34.26 13.42 0.12 0.02 0.24
## TissueFraction_GMWM 1.00 0.14 -0.95 1.52 0.00
#LAG - count individual subject N and N of females
lag_sub_sex <- lag_dat %>%
dplyr::select(subj_id, female)
lag_unique_subs<-unique(lag_sub_sex)
length(lag_unique_subs$subj_id)
## [1] 95
sum(lag_unique_subs$female)
## [1] 47
describe(lag_dat)
## vars n mean sd median trimmed mad min
## study_code* 1 319 159.94 92.14 160.00 160.00 118.61 1.00
## subj_id* 2 319 40.08 24.50 41.00 38.93 28.17 1.00
## spec_id 3 318 7743.17 3545.38 6379.50 7568.65 3846.61 3118.00
## date_scan* 4 319 142.76 81.83 142.00 142.92 103.78 1.00
## hand* 5 319 4.64 0.90 5.00 4.88 0.00 1.00
## female 6 319 0.47 0.50 0.00 0.46 0.00 0.00
## mri_age_y 7 319 5.95 1.91 5.36 5.80 1.80 2.41
## folder* 8 319 160.00 92.23 160.00 160.00 118.61 1.00
## File_ID* 9 319 160.00 92.23 160.00 160.00 118.61 1.00
## fGM 10 319 0.62 0.10 0.64 0.63 0.10 0.30
## fWM 11 319 0.35 0.11 0.34 0.34 0.11 0.13
## fCSF 12 319 0.03 0.02 0.03 0.03 0.01 0.00
## NAA_conc_molal 13 317 14.38 1.02 14.35 14.37 0.87 11.38
## Cre_PCr_conc_molal 14 319 10.24 0.91 10.17 10.23 0.82 7.28
## Cho_GPC_PCh_conc_molal 15 319 2.21 0.27 2.20 2.20 0.24 1.40
## Ins_conc_molal 16 318 6.37 1.19 6.37 6.39 1.08 2.04
## Glu_conc_molal 17 319 17.89 1.84 17.87 17.88 1.71 11.62
## Glu_Gln_conc_molal 18 318 21.67 2.16 21.74 21.71 2.01 14.26
## max range skew kurtosis se
## study_code* 318.00 317.00 0.00 -1.21 5.16
## subj_id* 95.00 94.00 0.29 -0.81 1.37
## spec_id 14205.00 11087.00 0.35 -1.37 198.82
## date_scan* 283.00 282.00 0.00 -1.19 4.58
## hand* 6.00 5.00 -2.34 4.43 0.05
## female 1.00 1.00 0.12 -1.99 0.03
## mri_age_y 11.13 8.72 0.66 -0.47 0.11
## folder* 319.00 318.00 0.00 -1.21 5.16
## File_ID* 319.00 318.00 0.00 -1.21 5.16
## fGM 0.80 0.50 -0.76 0.41 0.01
## fWM 0.66 0.53 0.53 0.04 0.01
## fCSF 0.17 0.17 2.27 9.13 0.00
## NAA_conc_molal 18.06 6.68 0.20 0.99 0.06
## Cre_PCr_conc_molal 14.09 6.81 0.17 1.38 0.05
## Cho_GPC_PCh_conc_molal 3.21 1.81 0.23 0.81 0.02
## Ins_conc_molal 11.78 9.74 -0.13 1.68 0.07
## Glu_conc_molal 24.87 13.25 0.02 0.86 0.10
## Glu_Gln_conc_molal 29.13 14.87 -0.20 0.65 0.12
#Calculate total Ns from both datasets combined
all_dat<-bind_rows(acg_dat_tf, lag_dat)
length(unique(all_dat$File_ID))
## [1] 431
length(unique(all_dat$subj_id))
## [1] 124
all_sub_sex <- all_dat %>%
dplyr::select(subj_id, female)
all_unique_subs<-unique(all_sub_sex)
sum(all_unique_subs$female)
## [1] 61
describe(all_dat)
## vars n mean sd median trimmed mad min
## study_code* 1 431 215.44 124.06 215.00 215.47 158.64 1.00
## subj_id* 2 431 52.42 32.22 52.00 50.74 37.06 1.00
## spec_id 3 430 7061.14 3604.41 5839.50 6832.78 3949.65 2058.00
## date_scan* 4 431 182.91 105.07 181.00 183.01 133.43 1.00
## hand* 5 431 4.63 0.92 5.00 4.86 0.00 1.00
## female 6 431 0.47 0.50 0.00 0.46 0.00 0.00
## mri_age_y 7 431 5.47 1.92 4.95 5.29 1.67 2.34
## folder* 8 431 215.54 124.13 216.00 215.55 158.64 1.00
## File_ID* 9 431 216.00 124.56 216.00 216.00 160.12 1.00
## fGM 10 431 0.66 0.11 0.67 0.67 0.11 0.30
## fWM 11 431 0.27 0.17 0.29 0.27 0.17 0.00
## fCSF 12 431 0.07 0.08 0.03 0.06 0.03 0.00
## NAA_conc_molal 13 429 14.54 1.11 14.52 14.51 0.97 11.38
## Cre_PCr_conc_molal 14 431 10.72 1.23 10.54 10.66 1.10 7.28
## Cho_GPC_PCh_conc_molal 15 430 2.28 0.31 2.26 2.27 0.26 1.40
## Ins_conc_molal 16 429 6.71 1.40 6.66 6.69 1.28 2.04
## Glu_conc_molal 17 431 19.08 2.78 18.54 18.90 2.53 11.62
## Glu_Gln_conc_molal 18 430 23.03 3.23 22.54 22.84 2.77 14.26
## TissueFraction_GMWM 19 112 0.96 0.03 0.96 0.96 0.03 0.86
## max range skew kurtosis se
## study_code* 429.00 428.00 0.00 -1.21 5.98
## subj_id* 124.00 123.00 0.34 -0.76 1.55
## spec_id 14205.00 12147.00 0.45 -1.19 173.82
## date_scan* 364.00 363.00 0.01 -1.18 5.06
## hand* 6.00 5.00 -2.30 4.31 0.04
## female 1.00 1.00 0.12 -1.99 0.02
## mri_age_y 11.13 8.79 0.79 -0.09 0.09
## folder* 430.00 429.00 0.00 -1.20 5.98
## File_ID* 431.00 430.00 0.00 -1.21 6.00
## fGM 0.87 0.57 -0.61 0.11 0.01
## fWM 0.66 0.66 -0.09 -0.88 0.01
## fCSF 0.36 0.36 1.38 0.88 0.00
## NAA_conc_molal 18.30 6.91 0.18 0.49 0.05
## Cre_PCr_conc_molal 14.76 7.48 0.45 0.20 0.06
## Cho_GPC_PCh_conc_molal 3.33 1.93 0.46 0.74 0.02
## Ins_conc_molal 11.78 9.74 0.08 0.70 0.07
## Glu_conc_molal 28.20 16.58 0.54 0.05 0.13
## Glu_Gln_conc_molal 34.26 20.00 0.54 0.33 0.16
## TissueFraction_GMWM 1.00 0.14 -0.95 1.52 0.00
run mixed-effects models for ACG with participant as random effect, age, sex and age x sex interaction as fixed effects NAA run on acg_data_molal_outliers_removed_n113.csv
acg_naa_age<- lmer(NAA_conc_molal ~ mri_age_y + (1 | subj_id), data=acg_dat, REML=FALSE)
summary(acg_naa_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: NAA_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: acg_dat
##
## AIC BIC logLik deviance df.resid
## 386.2 397.1 -189.1 378.2 110
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.53494 -0.38474 0.05128 0.39819 1.68394
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 1.1162 1.0565
## Residual 0.6081 0.7798
## Number of obs: 114, groups: subj_id, 103
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 13.7981 0.4547 109.4797 30.343 <2e-16 ***
## mri_age_y 0.2633 0.1064 106.5464 2.474 0.0149 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.959
acg_naa_age_sex<- lmer(NAA_conc_molal ~ mri_age_y + female + (1 | subj_id), data=acg_dat, REML=FALSE)
summary(acg_naa_age_sex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: NAA_conc_molal ~ mri_age_y + female + (1 | subj_id)
## Data: acg_dat
##
## AIC BIC logLik deviance df.resid
## 388.1 401.8 -189.0 378.1 109
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.55068 -0.39106 0.04551 0.38551 1.66978
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 1.1158 1.0563
## Residual 0.6073 0.7793
## Number of obs: 114, groups: subj_id, 103
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 13.82199 0.46185 111.05515 29.927 <2e-16 ***
## mri_age_y 0.26594 0.10677 106.17924 2.491 0.0143 *
## female -0.07582 0.25881 100.11358 -0.293 0.7702
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.926
## female -0.177 -0.083
anova(acg_naa_age,acg_naa_age_sex)
## Data: acg_dat
## Models:
## acg_naa_age: NAA_conc_molal ~ mri_age_y + (1 | subj_id)
## acg_naa_age_sex: NAA_conc_molal ~ mri_age_y + female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## acg_naa_age 4 386.18 397.13 -189.09 378.18
## acg_naa_age_sex 5 388.10 401.78 -189.05 378.10 0.0858 1 0.7696
acg_naa_ageXsex<- lmer(NAA_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id), data=acg_dat, REML=FALSE)
summary(acg_naa_ageXsex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: NAA_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 |
## subj_id)
## Data: acg_dat
##
## AIC BIC logLik deviance df.resid
## 389.9 406.3 -188.9 377.9 108
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.56994 -0.38025 0.02679 0.37635 1.69766
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 1.1133 1.0552
## Residual 0.6064 0.7787
## Number of obs: 114, groups: subj_id, 103
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 13.60715 0.65194 107.13020 20.872 <2e-16 ***
## mri_age_y 0.31957 0.15682 108.52117 2.038 0.044 *
## female 0.33340 0.91434 110.87125 0.365 0.716
## mri_age_y:female -0.09982 0.21393 109.48200 -0.467 0.642
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y female
## mri_age_y -0.964
## female -0.713 0.687
## mri_g_y:fml 0.706 -0.733 -0.959
anova(acg_naa_age,acg_naa_ageXsex)
## Data: acg_dat
## Models:
## acg_naa_age: NAA_conc_molal ~ mri_age_y + (1 | subj_id)
## acg_naa_ageXsex: NAA_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## acg_naa_age 4 386.18 397.13 -189.09 378.18
## acg_naa_ageXsex 6 389.88 406.30 -188.94 377.88 0.3033 2 0.8593
#including sex in model does not significantly improve fit
Cre
acg_cre_age<- lmer(Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id), data=acg_dat, REML=FALSE)
summary(acg_cre_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: acg_dat
##
## AIC BIC logLik deviance df.resid
## 343.0 353.9 -167.5 335.0 110
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.1474 -0.3859 0.0273 0.3782 1.6415
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.6729 0.8203
## Residual 0.4905 0.7003
## Number of obs: 114, groups: subj_id, 103
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 11.68736 0.37778 111.76736 30.937 <2e-16 ***
## mri_age_y 0.08819 0.08855 109.41712 0.996 0.322
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.960
acg_cre_age_sex<- lmer(Cre_PCr_conc_molal ~ mri_age_y + female + (1 | subj_id), data=acg_dat, REML=FALSE)
summary(acg_cre_age_sex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cre_PCr_conc_molal ~ mri_age_y + female + (1 | subj_id)
## Data: acg_dat
##
## AIC BIC logLik deviance df.resid
## 344.9 358.6 -167.5 334.9 109
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.13116 -0.38405 0.00946 0.36438 1.62078
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.6730 0.8204
## Residual 0.4896 0.6997
## Number of obs: 114, groups: subj_id, 103
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 11.66830 0.38333 112.85093 30.439 <2e-16 ***
## mri_age_y 0.08605 0.08884 109.09172 0.969 0.335
## female 0.06095 0.21223 97.33741 0.287 0.775
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.928
## female -0.172 -0.085
anova(acg_cre_age,acg_cre_age_sex)
## Data: acg_dat
## Models:
## acg_cre_age: Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id)
## acg_cre_age_sex: Cre_PCr_conc_molal ~ mri_age_y + female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## acg_cre_age 4 343.00 353.94 -167.50 335.00
## acg_cre_age_sex 5 344.92 358.60 -167.46 334.92 0.0824 1 0.774
acg_cre_ageXsex<- lmer(Cre_PCr_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id), data=acg_dat, REML=FALSE)
summary(acg_cre_ageXsex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cre_PCr_conc_molal ~ mri_age_y + female + mri_age_y:female +
## (1 | subj_id)
## Data: acg_dat
##
## AIC BIC logLik deviance df.resid
## 345.6 362.0 -166.8 333.6 108
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.1400 -0.3706 0.0470 0.3804 1.6095
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.6889 0.8300
## Residual 0.4645 0.6816
## Number of obs: 114, groups: subj_id, 103
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 12.0953 0.5344 105.6197 22.634 <2e-16 ***
## mri_age_y -0.0206 0.1286 107.4284 -0.160 0.873
## female -0.7760 0.7549 111.9289 -1.028 0.306
## mri_age_y:female 0.2042 0.1767 110.6646 1.155 0.250
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y female
## mri_age_y -0.964
## female -0.708 0.682
## mri_g_y:fml 0.701 -0.728 -0.960
anova(acg_cre_age,acg_cre_ageXsex)
## Data: acg_dat
## Models:
## acg_cre_age: Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id)
## acg_cre_ageXsex: Cre_PCr_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## acg_cre_age 4 343.0 353.94 -167.5 335.0
## acg_cre_ageXsex 6 345.6 362.02 -166.8 333.6 1.402 2 0.4961
Cho
acg_cho_age<- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id), data=acg_dat, REML=FALSE)
summary(acg_cho_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: acg_dat
##
## AIC BIC logLik deviance df.resid
## 77.7 88.7 -34.9 69.7 109
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.1491 -0.5968 -0.1289 0.6062 2.4462
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.03149 0.1775
## Residual 0.07844 0.2801
## Number of obs: 113, groups: subj_id, 102
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.74337 0.11886 112.89053 23.08 <2e-16 ***
## mri_age_y -0.06346 0.02796 112.96130 -2.27 0.0251 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.963
acg_cho_age_sex<- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y + female + (1 | subj_id), data=acg_dat, REML=FALSE)
summary(acg_cho_age_sex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cho_GPC_PCh_conc_molal ~ mri_age_y + female + (1 | subj_id)
## Data: acg_dat
##
## AIC BIC logLik deviance df.resid
## 77.8 91.4 -33.9 67.8 108
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.19114 -0.63415 -0.08954 0.54134 2.51028
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.03166 0.1779
## Residual 0.07644 0.2765
## Number of obs: 113, groups: subj_id, 102
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.77042 0.11941 112.68644 23.201 <2e-16 ***
## mri_age_y -0.05992 0.02783 112.91175 -2.153 0.0334 *
## female -0.09031 0.06427 104.26220 -1.405 0.1629
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.931
## female -0.161 -0.091
anova(acg_cho_age,acg_cho_age_sex)
## Data: acg_dat
## Models:
## acg_cho_age: Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id)
## acg_cho_age_sex: Cho_GPC_PCh_conc_molal ~ mri_age_y + female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## acg_cho_age 4 77.741 88.651 -34.871 69.741
## acg_cho_age_sex 5 77.784 91.421 -33.892 67.784 1.9566 1 0.1619
acg_cho_ageXsex<- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id), data=acg_dat, REML=FALSE)
summary(acg_cho_ageXsex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cho_GPC_PCh_conc_molal ~ mri_age_y + female + mri_age_y:female +
## (1 | subj_id)
## Data: acg_dat
##
## AIC BIC logLik deviance df.resid
## 79.4 95.7 -33.7 67.4 107
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.14358 -0.60659 -0.08904 0.56303 2.57414
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.03248 0.1802
## Residual 0.07531 0.2744
## Number of obs: 113, groups: subj_id, 102
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.69825 0.16339 108.50103 16.514 <2e-16 ***
## mri_age_y -0.04189 0.03941 110.43375 -1.063 0.290
## female 0.05678 0.23670 112.98909 0.240 0.811
## mri_age_y:female -0.03590 0.05555 112.91619 -0.646 0.519
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y female
## mri_age_y -0.964
## female -0.690 0.665
## mri_g_y:fml 0.684 -0.709 -0.963
anova(acg_cho_age,acg_cho_ageXsex)
## Data: acg_dat
## Models:
## acg_cho_age: Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id)
## acg_cho_ageXsex: Cho_GPC_PCh_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## acg_cho_age 4 77.741 88.651 -34.871 69.741
## acg_cho_ageXsex 6 79.369 95.734 -33.685 67.369 2.3716 2 0.3055
#including sex in model does not significantly improve fit
Ins
acg_ins_age<- lmer(Ins_conc_molal ~ mri_age_y + (1 | subj_id), data=acg_dat, REML=FALSE)
summary(acg_ins_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: acg_dat
##
## AIC BIC logLik deviance df.resid
## 419.4 430.4 -205.7 411.4 109
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.50885 -0.45772 0.08968 0.51909 1.59076
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.9245 0.9615
## Residual 1.3639 1.1678
## Number of obs: 113, groups: subj_id, 102
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 8.5136 0.5405 112.9851 15.751 <2e-16 ***
## mri_age_y -0.2166 0.1274 112.5308 -1.699 0.092 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.962
acg_ins_age_sex<- lmer(Ins_conc_molal ~ mri_age_y + female + (1 | subj_id), data=acg_dat, REML=FALSE)
summary(acg_ins_age_sex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y + female + (1 | subj_id)
## Data: acg_dat
##
## AIC BIC logLik deviance df.resid
## 420.2 433.9 -205.1 410.2 108
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.46750 -0.51393 0.02814 0.54321 1.52827
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.8927 0.9448
## Residual 1.3689 1.1700
## Number of obs: 113, groups: subj_id, 102
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 8.6021 0.5441 112.9446 15.810 <2e-16 ***
## mri_age_y -0.2014 0.1274 112.4347 -1.581 0.117
## female -0.3263 0.2957 100.4715 -1.103 0.273
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.930
## female -0.153 -0.102
anova(acg_ins_age,acg_ins_age_sex)
## Data: acg_dat
## Models:
## acg_ins_age: Ins_conc_molal ~ mri_age_y + (1 | subj_id)
## acg_ins_age_sex: Ins_conc_molal ~ mri_age_y + female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## acg_ins_age 4 419.45 430.36 -205.72 411.45
## acg_ins_age_sex 5 420.24 433.88 -205.12 410.24 1.2094 1 0.2714
acg_ins_ageXsex<- lmer(Ins_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id), data=acg_dat, REML=FALSE)
summary(acg_ins_ageXsex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 |
## subj_id)
## Data: acg_dat
##
## AIC BIC logLik deviance df.resid
## 421.1 437.5 -204.6 409.1 107
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.56504 -0.52674 0.07063 0.55229 1.68358
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.7497 0.8659
## Residual 1.4758 1.2148
## Number of obs: 113, groups: subj_id, 102
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 9.1424 0.7487 106.4512 12.212 <2e-16 ***
## mri_age_y -0.3378 0.1820 109.0038 -1.856 0.0661 .
## female -1.4527 1.0778 112.9997 -1.348 0.1804
## mri_age_y:female 0.2757 0.2540 112.8275 1.086 0.2799
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y female
## mri_age_y -0.965
## female -0.695 0.670
## mri_g_y:fml 0.691 -0.717 -0.962
anova(acg_ins_age,acg_ins_ageXsex)
## Data: acg_dat
## Models:
## acg_ins_age: Ins_conc_molal ~ mri_age_y + (1 | subj_id)
## acg_ins_ageXsex: Ins_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## acg_ins_age 4 419.45 430.36 -205.72 411.45
## acg_ins_ageXsex 6 421.12 437.48 -204.56 409.12 2.3288 2 0.3121
Glx
acg_glx_age<- lmer(Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id), data=acg_dat, REML=FALSE)
summary(acg_glx_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: acg_dat
##
## AIC BIC logLik deviance df.resid
## 545.1 556.0 -268.5 537.1 110
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.48552 -0.36425 -0.00765 0.43429 1.69475
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 4.656 2.158
## Residual 2.327 1.525
## Number of obs: 114, groups: subj_id, 103
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 25.7032 0.9114 108.1462 28.201 <2e-16 ***
## mri_age_y 0.2755 0.2132 104.7745 1.292 0.199
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.959
acg_glx_age_sex<- lmer(Glu_Gln_conc_molal ~ mri_age_y + female + (1 | subj_id), data=acg_dat, REML=FALSE)
summary(acg_glx_age_sex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y + female + (1 | subj_id)
## Data: acg_dat
##
## AIC BIC logLik deviance df.resid
## 547.0 560.7 -268.5 537.0 109
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.48000 -0.38265 -0.01407 0.42400 1.71091
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 4.645 2.155
## Residual 2.331 1.527
## Number of obs: 114, groups: subj_id, 103
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 25.6579 0.9261 110.0599 27.706 <2e-16 ***
## mri_age_y 0.2705 0.2139 104.4176 1.265 0.209
## female 0.1438 0.5210 99.7183 0.276 0.783
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.926
## female -0.178 -0.083
anova(acg_glx_age,acg_glx_age_sex)
## Data: acg_dat
## Models:
## acg_glx_age: Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id)
## acg_glx_age_sex: Glu_Gln_conc_molal ~ mri_age_y + female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## acg_glx_age 4 545.08 556.03 -268.54 537.08
## acg_glx_age_sex 5 547.00 560.69 -268.50 537.00 0.0762 1 0.7826
acg_glx_ageXsex<- lmer(Glu_Gln_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id), data=acg_dat, REML=FALSE)
summary(acg_glx_ageXsex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y + female + mri_age_y:female +
## (1 | subj_id)
## Data: acg_dat
##
## AIC BIC logLik deviance df.resid
## 546.8 563.2 -267.4 534.8 108
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.52992 -0.42202 0.06969 0.40852 1.64675
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 4.545 2.132
## Residual 2.296 1.515
## Number of obs: 114, groups: subj_id, 103
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 27.0251 1.2998 107.2030 20.792 <2e-16 ***
## mri_age_y -0.0707 0.3126 108.5551 -0.226 0.822
## female -2.4433 1.8178 110.1952 -1.344 0.182
## mri_age_y:female 0.6311 0.4252 108.6629 1.484 0.141
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y female
## mri_age_y -0.964
## female -0.715 0.689
## mri_g_y:fml 0.708 -0.735 -0.959
anova(acg_glx_age,acg_glx_ageXsex)
## Data: acg_dat
## Models:
## acg_glx_age: Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id)
## acg_glx_ageXsex: Glu_Gln_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## acg_glx_age 4 545.08 556.03 -268.54 537.08
## acg_glx_ageXsex 6 546.82 563.24 -267.41 534.82 2.2581 2 0.3233
Create scatter plot with regression line based on model predictions NAA
acg_dat <- read.csv("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/acg_data_molal_outliers_removed_n114.csv")
#pull intercept and slope from model for regression line
fixef.acg_naa<-fixef(acg_naa_age)
#plot
plot_acg_naa_age<-ggplot(acg_dat, aes(x=mri_age_y, y=NAA_conc_molal,color=as.factor(female))) +
geom_point() +
labs(title = "Anterior Cingulate", x = "Age (years)", y = "tNAA (molal)") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_smooth(method = "lm", se = FALSE, aes(x=mri_age_y, y=NAA_conc_molal, group=as.factor(subj_id)), size = .3, show.legend = FALSE) +
geom_abline(aes(intercept = fixef.acg_naa[[1]], slope= fixef.acg_naa[[2]])) +
theme_classic()
plot_acg_naa_age
## `geom_smooth()` using formula 'y ~ x'
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/acg_naa_age_viridis.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
Cho
#pull intercept and slope from model for regression line
fixef.acg_cho<-fixef(acg_cho_age)
#plot
plot_acg_cho_age<-ggplot(acg_dat, aes(x=mri_age_y, y=Cho_GPC_PCh_conc_molal,color=as.factor(female))) +
geom_point() +
labs(title = "Anterior Cingulate", x = "Age (years)", y = "tCho (molal)") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_smooth(method = "lm", se = FALSE, aes(x=mri_age_y, y=Cho_GPC_PCh_conc_molal, group=as.factor(subj_id)), size = .3, show.legend = FALSE) +
geom_abline(aes(intercept = fixef.acg_cho[[1]], slope= fixef.acg_cho[[2]])) +
theme_classic()
plot_acg_cho_age
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/acg_cho_age_viridis.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
Ins
#pull intercept and slope from model for regression line
fixef.acg_ins<-fixef(acg_ins_age)
#plot
plot_acg_ins_age<-ggplot(acg_dat, aes(x=mri_age_y, y=Ins_conc_molal,color=as.factor(female))) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, aes(x=mri_age_y, y=Ins_conc_molal, group=as.factor(subj_id)), size = .3, show.legend = FALSE) +
labs(title = "Anterior Cingulate", x = "Age (years)", y = "Ins (molal)") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_abline(aes(intercept = fixef.acg_ins[[1]], slope= fixef.acg_ins[[2]])) +
theme_classic()
plot_acg_ins_age
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/acg_ins_age_viridis.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
run mixed-effects models for lag with participant as random effect, age, sex and age x sex interaction as fixed effects NAA, substantial longitudinal data so we include random slope run on lag_data_molal_outliers_removed_n320.csv
#basic model effect of age on intercept
lag_naa_age<- lmer(NAA_conc_molal ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_naa_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: NAA_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 890.5 905.5 -441.2 882.5 313
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.4414 -0.5745 -0.0083 0.5519 3.6446
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1617 0.4022
## Residual 0.8208 0.9060
## Number of obs: 317, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 13.80537 0.18530 307.84404 74.504 < 2e-16 ***
## mri_age_y 0.09907 0.02891 315.86987 3.427 0.000692 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.929
lag_naa_age_sex<- lmer(NAA_conc_molal ~ mri_age_y + female + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_naa_age_sex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: NAA_conc_molal ~ mri_age_y + female + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 892.5 911.3 -441.2 882.5 312
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.4416 -0.5747 -0.0081 0.5516 3.6449
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1618 0.4022
## Residual 0.8207 0.9059
## Number of obs: 317, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.380e+01 1.944e-01 2.886e+02 71.032 < 2e-16 ***
## mri_age_y 9.906e-02 2.893e-02 3.159e+02 3.424 0.000698 ***
## female 9.009e-04 1.370e-01 9.430e+01 0.007 0.994767
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.874
## female -0.302 -0.038
anova(lag_naa_age,lag_naa_age_sex)
## Data: lag_dat
## Models:
## lag_naa_age: NAA_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_naa_age_sex: NAA_conc_molal ~ mri_age_y + female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_naa_age 4 890.46 905.50 -441.23 882.46
## lag_naa_age_sex 5 892.46 911.26 -441.23 882.46 0 1 0.9948
lag_naa_ageXsex<- lmer(NAA_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_naa_ageXsex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: NAA_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 |
## subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 894.4 916.9 -441.2 882.4 311
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.4590 -0.5791 -0.0128 0.5574 3.6391
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1630 0.4037
## Residual 0.8197 0.9054
## Number of obs: 317, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 13.76246 0.24760 311.87849 55.584 < 2e-16 ***
## mri_age_y 0.10629 0.03897 313.81364 2.727 0.00674 **
## female 0.09800 0.37334 306.49603 0.262 0.79312
## mri_age_y:female -0.01622 0.05816 316.19232 -0.279 0.78056
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y female
## mri_age_y -0.924
## female -0.663 0.613
## mri_g_y:fml 0.619 -0.670 -0.930
anova(lag_naa_age,lag_naa_ageXsex)
## Data: lag_dat
## Models:
## lag_naa_age: NAA_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_naa_ageXsex: NAA_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_naa_age 4 890.46 905.50 -441.23 882.46
## lag_naa_ageXsex 6 894.39 916.94 -441.19 882.39 0.0773 2 0.9621
#including sex in model does not significantly improve fit
Cre
lag_cre_age<- lmer(Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cre_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 842.9 858.0 -417.4 834.9 315
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.9830 -0.5313 -0.1227 0.5456 4.1744
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.08589 0.2931
## Residual 0.72923 0.8539
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 10.48668 0.16753 306.60267 62.598 <2e-16 ***
## mri_age_y -0.04066 0.02635 318.92136 -1.543 0.124
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.937
lag_cre_age_sex<- lmer(Cre_PCr_conc_molal ~ mri_age_y + female + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cre_age_sex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cre_PCr_conc_molal ~ mri_age_y + female + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 844.3 863.1 -417.1 834.3 314
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.9572 -0.5697 -0.1123 0.5313 4.2177
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.08565 0.2927
## Residual 0.72781 0.8531
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 10.44766 0.17431 286.83354 59.936 <2e-16 ***
## mri_age_y -0.04156 0.02635 318.93270 -1.577 0.116
## female 0.09379 0.11727 85.32006 0.800 0.426
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.887
## female -0.280 -0.043
anova(lag_cre_age,lag_cre_age_sex)
## Data: lag_dat
## Models:
## lag_cre_age: Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_cre_age_sex: Cre_PCr_conc_molal ~ mri_age_y + female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_cre_age 4 842.89 857.95 -417.45 834.89
## lag_cre_age_sex 5 844.25 863.08 -417.13 834.25 0.6389 1 0.4241
lag_cre_ageXsex<- lmer(Cre_PCr_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cre_ageXsex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cre_PCr_conc_molal ~ mri_age_y + female + mri_age_y:female +
## (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 844.6 867.2 -416.3 832.6 313
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.9698 -0.5663 -0.0893 0.5748 4.2575
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.08168 0.2858
## Residual 0.72658 0.8524
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 10.63021 0.22419 311.72231 47.416 <2e-16 ***
## mri_age_y -0.07265 0.03571 318.24306 -2.035 0.0427 *
## female -0.31437 0.33567 305.61946 -0.937 0.3497
## mri_age_y:female 0.06830 0.05275 318.99464 1.295 0.1963
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y female
## mri_age_y -0.934
## female -0.668 0.624
## mri_g_y:fml 0.632 -0.677 -0.938
anova(lag_cre_age,lag_cre_ageXsex)
## Data: lag_dat
## Models:
## lag_cre_age: Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_cre_ageXsex: Cre_PCr_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_cre_age 4 842.89 857.95 -417.45 834.89
## lag_cre_ageXsex 6 844.59 867.18 -416.29 832.59 2.3043 2 0.316
Cho
lag_cho_age<- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cho_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 51.3 66.4 -21.7 43.3 315
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.6543 -0.5762 -0.0565 0.4634 4.1262
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.01502 0.1225
## Residual 0.05605 0.2367
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.344024 0.049129 308.131799 47.711 < 2e-16 ***
## mri_age_y -0.023002 0.007589 315.366670 -3.031 0.00264 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.921
lag_cho_age_sex<- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y + female + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cho_age_sex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cho_GPC_PCh_conc_molal ~ mri_age_y + female + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 51.7 70.5 -20.8 41.7 314
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.6281 -0.5906 -0.0649 0.4555 4.1760
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.01483 0.1218
## Residual 0.05582 0.2363
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.364836 0.051611 280.421342 45.820 < 2e-16 ***
## mri_age_y -0.022573 0.007577 315.506853 -2.979 0.00312 **
## female -0.048983 0.038188 80.965276 -1.283 0.20326
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.860
## female -0.314 -0.044
anova(lag_cho_age,lag_cho_age_sex)
## Data: lag_dat
## Models:
## lag_cho_age: Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_cho_age_sex: Cho_GPC_PCh_conc_molal ~ mri_age_y + female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_cho_age 4 51.328 66.388 -21.664 43.328
## lag_cho_age_sex 5 51.687 70.513 -20.843 41.687 1.6406 1 0.2002
lag_cho_ageXsex<- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cho_ageXsex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cho_GPC_PCh_conc_molal ~ mri_age_y + female + mri_age_y:female +
## (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 49.8 72.4 -18.9 37.8 313
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.6601 -0.5416 -0.0420 0.4625 4.0573
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.01475 0.1214
## Residual 0.05509 0.2347
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.285246 0.065245 312.113904 35.025 <2e-16 ***
## mri_age_y -0.008982 0.010200 312.512541 -0.881 0.3793
## female 0.129574 0.098069 307.561559 1.321 0.1874
## mri_age_y:female -0.029877 0.015123 315.968349 -1.976 0.0491 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y female
## mri_age_y -0.916
## female -0.665 0.609
## mri_g_y:fml 0.618 -0.675 -0.922
anova(lag_cho_age,lag_cho_ageXsex)
## Data: lag_dat
## Models:
## lag_cho_age: Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_cho_ageXsex: Cho_GPC_PCh_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_cho_age 4 51.328 66.388 -21.664 43.328
## lag_cho_ageXsex 6 49.808 72.399 -18.904 37.808 5.5197 2 0.0633 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#including sex in model does not significantly improve fit
Ins
lag_ins_age<- lmer(Ins_conc_molal ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_ins_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1011.1 1026.2 -501.6 1003.1 314
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.3931 -0.5604 -0.0184 0.5920 4.6446
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1771 0.4208
## Residual 1.2267 1.1076
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 6.28387 0.21993 305.18747 28.573 <2e-16 ***
## mri_age_y 0.01641 0.03450 317.63548 0.476 0.635
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.934
lag_ins_age_sex<- lmer(Ins_conc_molal ~ mri_age_y + female + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_ins_age_sex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y + female + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1013.1 1031.9 -501.6 1003.1 313
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.3948 -0.5596 -0.0182 0.5914 4.6437
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1768 0.4205
## Residual 1.2269 1.1076
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 6.285281 0.229479 281.833122 27.389 <2e-16 ***
## mri_age_y 0.016437 0.034540 317.647030 0.476 0.634
## female -0.003309 0.157674 78.794907 -0.021 0.983
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.881
## female -0.286 -0.045
anova(lag_ins_age,lag_ins_age_sex)
## Data: lag_dat
## Models:
## lag_ins_age: Ins_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_ins_age_sex: Ins_conc_molal ~ mri_age_y + female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_ins_age 4 1011.1 1026.2 -501.57 1003.1
## lag_ins_age_sex 5 1013.1 1031.9 -501.57 1003.1 4e-04 1 0.9835
lag_ins_ageXsex<- lmer(Ins_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_ins_ageXsex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 |
## subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1015.0 1037.5 -501.5 1003.0 312
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.4193 -0.5414 -0.0150 0.5903 4.6279
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.177 0.4207
## Residual 1.226 1.1073
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 6.360441 0.295373 310.066907 21.534 <2e-16 ***
## mri_age_y 0.003593 0.046928 316.302185 0.077 0.939
## female -0.170402 0.442479 303.735635 -0.385 0.700
## mri_age_y:female 0.028020 0.069300 317.780067 0.404 0.686
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y female
## mri_age_y -0.930
## female -0.668 0.621
## mri_g_y:fml 0.630 -0.677 -0.934
anova(lag_ins_age,lag_ins_ageXsex)
## Data: lag_dat
## Models:
## lag_ins_age: Ins_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_ins_ageXsex: Ins_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_ins_age 4 1011.1 1026.2 -501.57 1003.1
## lag_ins_ageXsex 6 1015.0 1037.5 -501.48 1003.0 0.1639 2 0.9213
Glx
lag_glx_age<- lmer(Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
## boundary (singular) fit: see ?isSingular
# boundary (singular) fit: model is almost/near singular (parameters are on the boundary of the feasible parameter space: random effects variance = 0)
summary(lag_glx_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1382.3 1397.4 -687.2 1374.3 314
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7144 -0.6884 0.0219 0.6876 3.5966
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.00 0.0
## Residual 4.41 2.1
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 23.21510 0.38755 318.00000 59.902 < 2e-16 ***
## mri_age_y -0.25957 0.06216 318.00000 -4.176 3.84e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.953
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
lag_glx_age_sex<- lmer(Glu_Gln_conc_molal ~ mri_age_y + female + (1 | subj_id), data=lag_dat, REML=FALSE)
## boundary (singular) fit: see ?isSingular
summary(lag_glx_age_sex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y + female + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1382.5 1401.3 -686.2 1372.5 313
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.8080 -0.6873 0.0182 0.7211 3.6789
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.000 0.000
## Residual 4.385 2.094
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 23.08202 0.39872 318.00000 57.890 < 2e-16 ***
## mri_age_y -0.26233 0.06202 318.00000 -4.230 3.06e-05 ***
## female 0.31902 0.23544 318.00000 1.355 0.176
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.915
## female -0.246 -0.033
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(lag_glx_age,lag_glx_age_sex)
## Data: lag_dat
## Models:
## lag_glx_age: Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_glx_age_sex: Glu_Gln_conc_molal ~ mri_age_y + female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_glx_age 4 1382.3 1397.4 -687.16 1374.3
## lag_glx_age_sex 5 1382.5 1401.3 -686.25 1372.5 1.8307 1 0.176
lag_glx_ageXsex<- lmer(Glu_Gln_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id), data=lag_dat, REML=FALSE)
## boundary (singular) fit: see ?isSingular
summary(lag_glx_ageXsex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y + female + mri_age_y:female +
## (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1383.5 1406.1 -685.8 1371.5 312
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7641 -0.7038 0.0008 0.7017 3.6964
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.000 0.000
## Residual 4.371 2.091
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 23.4109 0.5179 318.0000 45.206 < 2e-16 ***
## mri_age_y -0.3182 0.0837 318.0000 -3.802 0.000172 ***
## female -0.4159 0.7766 318.0000 -0.536 0.592624
## mri_age_y:female 0.1235 0.1244 318.0000 0.993 0.321472
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y female
## mri_age_y -0.951
## female -0.667 0.634
## mri_g_y:fml 0.640 -0.673 -0.953
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(lag_glx_age,lag_glx_ageXsex)
## Data: lag_dat
## Models:
## lag_glx_age: Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_glx_ageXsex: Glu_Gln_conc_molal ~ mri_age_y + female + mri_age_y:female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_glx_age 4 1382.3 1397.4 -687.16 1374.3
## lag_glx_ageXsex 6 1383.5 1406.1 -685.76 1371.5 2.8152 2 0.2447
Create scatter plot with regression line based on model predictions NAA
#pull intercept and slope from model for regression line
fixef.lag_naa<-fixef(lag_naa_age)
#plot
plot_lag_naa_age<-ggplot(lag_dat, aes(x=mri_age_y, y=NAA_conc_molal,color=as.factor(female))) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, aes(x=mri_age_y, y=NAA_conc_molal, group=as.factor(subj_id)), size = .3, show.legend = FALSE) +
labs(title = "Left Temporo-Parietal", x = "Age (years)", y = "tNAA (molal)") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_abline(aes(intercept = fixef.lag_naa[[1]], slope= fixef.lag_naa[[2]])) +
theme_classic()
plot_lag_naa_age
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 2 rows containing non-finite values (stat_smooth).
## Warning: Removed 2 rows containing missing values (geom_point).
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/lag_naa_age_viridis.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 2 rows containing non-finite values (stat_smooth).
## Warning: Removed 2 rows containing missing values (geom_point).
Cho
#pull intercept and slope from model for regression line
fixef.lag_cho<-fixef(lag_cho_age)
#plot
plot_lag_cho_age<-ggplot(lag_dat, aes(x=mri_age_y, y=Cho_GPC_PCh_conc_molal,color=as.factor(female))) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, aes(x=mri_age_y, y=Cho_GPC_PCh_conc_molal, group=as.factor(subj_id)), size = .3, show.legend = FALSE) +
labs(title = "Left Temporo-Parietal", x = "Age (years)", y = "tCho (molal)") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_abline(aes(intercept = fixef.lag_cho[[1]], slope= fixef.lag_cho[[2]])) +
theme_classic()
plot_lag_cho_age
## `geom_smooth()` using formula 'y ~ x'
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/lag_cho_age_viridis.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
Glx
#pull intercept and slope from model for regression line
fixef.lag_glx<-fixef(lag_glx_age)
#plot
plot_lag_glx_age<-ggplot(lag_dat, aes(x=mri_age_y, y=Glu_Gln_conc_molal,color=as.factor(female))) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, aes(x=mri_age_y, y=Glu_Gln_conc_molal, group=as.factor(subj_id)), size = .3, show.legend = FALSE) +
labs(title = "Left Temporo-Parietal", x = "Age (years)", y = "Glx (molal)") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_abline(aes(intercept = fixef.lag_glx[[1]], slope= fixef.lag_glx[[2]])) +
theme_classic()
plot_lag_glx_age
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/lag_glx_age_viridis.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
##Combine results plots into 1 figure Simplify plots to legend & region don’t repeat in each panel
library(patchwork)
p1_acg_naa_age<-plot_acg_naa_age +
geom_point() +
geom_line(aes(group = as.factor(subj_id))) +
labs(title = "Anterior Cingulate", x = "Age (years)", y = "tNAA (molal)") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_abline(aes(intercept = fixef.acg_naa[[1]], slope= fixef.acg_naa[[2]])) +
theme_classic() +
theme(plot.title= element_text(hjust = 0.5))
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
p4_lag_naa_age<-plot_lag_naa_age +
geom_point() +
geom_line(aes(group = as.factor(subj_id))) +
labs(title = "Left Temporo-Parietal", x = "Age (years)", y = "tNAA (molal)") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
theme_classic() +
#theme(legend.position = c(0.7, 0.95), legend.background = element_rect(fill='transparent')) +
geom_abline(aes(intercept = fixef.lag_naa[[1]], slope= fixef.lag_naa[[2]])) +
theme(plot.title= element_text(hjust = 0.5))
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
p2_acg_cho_age<-plot_acg_cho_age +
geom_point() +
geom_line(aes(group = as.factor(subj_id))) +
labs(x = "Age (years)", y = "tCho (molal)") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_abline(aes(intercept = fixef.acg_cho[[1]], slope= fixef.acg_cho[[2]])) +
theme_classic()
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
p5_lag_cho_age<-plot_lag_cho_age +
geom_point() +
geom_line(aes(group = as.factor(subj_id))) +
labs(x = "Age (years)", y = "tCho (molal)") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_abline(aes(intercept = fixef.lag_cho[[1]], slope= fixef.lag_cho[[2]])) +
theme_classic()
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
p3_acg_ins_age<-plot_acg_ins_age +
geom_point() +
geom_line(aes(group = as.factor(subj_id))) +
labs(x = "Age (years)", y = "Ins (molal)") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_abline(aes(intercept = fixef.acg_ins[[1]], slope= fixef.acg_ins[[2]])) +
theme_classic()
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
p6_lag_glx_age<-plot_lag_glx_age +
geom_point() +
geom_line(aes(group = as.factor(subj_id))) +
labs(x = "Age (years)", y = "Glx (molal)") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_abline(aes(intercept = fixef.lag_glx[[1]], slope= fixef.lag_glx[[2]])) +
theme_classic()
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
results_fig<-p1_acg_naa_age + p4_lag_naa_age + p2_acg_cho_age + p5_lag_cho_age + p3_acg_ins_age + p6_lag_glx_age + plot_layout(nrow=3, guides ='collect')
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/results_fig_grid_viridis.png", results_fig, width = 2000, units = "px")
## Saving 2000 x 1500 px image
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 2 rows containing non-finite values (stat_smooth).
## Warning: Removed 2 rows containing missing values (geom_point).
## Warning: Removed 2 rows containing missing values (geom_point).
## Warning: Removed 2 row(s) containing missing values (geom_path).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
## Warning: Removed 1 rows containing missing values (geom_point).
## Warning: Removed 1 row(s) containing missing values (geom_path).
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
## Warning: Removed 1 rows containing missing values (geom_point).
## Warning: Removed 1 row(s) containing missing values (geom_path).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
## Warning: Removed 1 rows containing missing values (geom_point).
## Warning: Removed 1 row(s) containing missing values (geom_path).
##Correct for multiple comparisons Use FDR method (Benjamini & Hochberg) to correct for mutliple comparisons (5 metabolites x 2 voxels = 10 models)
## 19-01-2022: need to re-run if using these models!
#list models (voxel/metabolite pair)
models<- c("acg_naa", "acg_cr", "acg_cho", "acg_ins", "acg_glx", "lag_naa", "lag_cr", "lag_cho", "lag_ins", "lag_glx")
#list p-values for each model, matching order of models
p<-c(.0217, .307, .0258, .0494, .23, .00093, .115, .00229, .636, 0)
fdr_table<-data.frame(models, p)
fdr_table$p_fdr<-p.adjust(p, method = "fdr", n= length(p))
fdr_table
## models p p_fdr
## 1 acg_naa 0.02170 0.051600000
## 2 acg_cr 0.30700 0.341111111
## 3 acg_cho 0.02580 0.051600000
## 4 acg_ins 0.04940 0.082333333
## 5 acg_glx 0.23000 0.287500000
## 6 lag_naa 0.00093 0.004650000
## 7 lag_cr 0.11500 0.164285714
## 8 lag_cho 0.00229 0.007633333
## 9 lag_ins 0.63600 0.636000000
## 10 lag_glx 0.00000 0.000000000
#run FDR without LAG-Glx in case it's invalid:
p2<-c(.0217, .307, .0258, .0494, .23, .00093, .115, .00229, .636)
p.adjust(p2, method = "fdr", n= length(p2))
## [1] 0.0580500 0.3453750 0.0580500 0.0889200 0.2957143 0.0083700 0.1725000
## [8] 0.0103050 0.6360000
##Additional models Next steps following OHBM abstract submission (Dec. 2021): test random slopes (LAG only)
#read in data
lag_dat<-read.csv("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/lag_data_molal_outliers_removed_n319.csv")
#basic age model NAA
lag_naa_age<- lmer(NAA_conc_molal ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_naa_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: NAA_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 890.5 905.5 -441.2 882.5 313
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.4414 -0.5745 -0.0083 0.5519 3.6446
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1617 0.4022
## Residual 0.8208 0.9060
## Number of obs: 317, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 13.80537 0.18530 307.84404 74.504 < 2e-16 ***
## mri_age_y 0.09907 0.02891 315.86987 3.427 0.000692 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.929
#test random slope NAA
lag_naa_age_randslope <- lmer(NAA_conc_molal ~ mri_age_y + (1 + mri_age_y | subj_id), data=lag_dat, REML=FALSE)
summary(lag_naa_age_randslope)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: NAA_conc_molal ~ mri_age_y + (1 + mri_age_y | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 893.8 916.3 -440.9 881.8 311
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.4510 -0.5798 -0.0277 0.5489 3.6970
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subj_id (Intercept) 0.447062 0.66863
## mri_age_y 0.005553 0.07452 -0.81
## Residual 0.800539 0.89473
## Number of obs: 317, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 13.79901 0.19514 85.30830 70.71 < 2e-16 ***
## mri_age_y 0.10058 0.03011 77.24404 3.34 0.00129 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.936
anova(lag_naa_age, lag_naa_age_randslope) #not sig.
## Data: lag_dat
## Models:
## lag_naa_age: NAA_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_naa_age_randslope: NAA_conc_molal ~ mri_age_y + (1 + mri_age_y | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_naa_age 4 890.46 905.50 -441.23 882.46
## lag_naa_age_randslope 6 893.78 916.33 -440.89 881.78 0.6841 2 0.7103
#basic age model Cre
lag_cre_age<- lmer(Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cre_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 842.9 858.0 -417.4 834.9 315
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.9830 -0.5313 -0.1227 0.5456 4.1744
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.08589 0.2931
## Residual 0.72923 0.8539
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 10.48668 0.16753 306.60267 62.598 <2e-16 ***
## mri_age_y -0.04066 0.02635 318.92136 -1.543 0.124
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.937
#test random slope Cre
lag_cre_age_randslope<- lmer(Cre_PCr_conc_molal ~ mri_age_y + (1 + mri_age_y | subj_id), data=lag_dat, REML=FALSE)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.00295184 (tol = 0.002, component 1)
#model failed to converge
#basic age model Cho
lag_cho_age<- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cho_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 51.3 66.4 -21.7 43.3 315
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.6543 -0.5762 -0.0565 0.4634 4.1262
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.01502 0.1225
## Residual 0.05605 0.2367
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.344024 0.049129 308.131799 47.711 < 2e-16 ***
## mri_age_y -0.023002 0.007589 315.366670 -3.031 0.00264 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.921
#test random slope Cho
lag_cho_age_randslope<- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 + mri_age_y | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cho_age_randslope)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 + mri_age_y | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 55.0 77.6 -21.5 43.0 313
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.6708 -0.5633 -0.0493 0.4770 4.1000
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subj_id (Intercept) 0.0216213 0.14704
## mri_age_y 0.0002908 0.01705 -0.56
## Residual 0.0549603 0.23444
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.347395 0.050147 57.717542 46.810 < 2e-16 ***
## mri_age_y -0.023708 0.007896 62.102149 -3.003 0.00385 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.924
#compare models
anova(lag_cho_age, lag_cho_age_randslope) #fit did not improve with inclusion of random slopes
## Data: lag_dat
## Models:
## lag_cho_age: Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_cho_age_randslope: Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 + mri_age_y | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_cho_age 4 51.328 66.388 -21.664 43.328
## lag_cho_age_randslope 6 55.005 77.596 -21.503 43.005 0.3224 2 0.8511
#basic age model Ins
lag_ins_age<- lmer(Ins_conc_molal ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_ins_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1011.1 1026.2 -501.6 1003.1 314
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.3931 -0.5604 -0.0184 0.5920 4.6446
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1771 0.4208
## Residual 1.2267 1.1076
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 6.28387 0.21993 305.18747 28.573 <2e-16 ***
## mri_age_y 0.01641 0.03450 317.63548 0.476 0.635
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.934
#test random slope Ins
lag_ins_age_randslope<- lmer(Ins_conc_molal ~ mri_age_y + (1 + mri_age_y | subj_id), data=lag_dat, REML=FALSE)
## boundary (singular) fit: see ?isSingular
summary(lag_ins_age_randslope)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y + (1 + mri_age_y | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1014.4 1037.0 -501.2 1002.4 312
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.2774 -0.5595 -0.0280 0.5844 4.5969
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subj_id (Intercept) 0.417074 0.64581
## mri_age_y 0.001306 0.03614 -1.00
## Residual 1.215463 1.10248
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 6.29844 0.22642 144.98523 27.817 <2e-16 ***
## mri_age_y 0.01360 0.03442 306.89030 0.395 0.693
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.937
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
#boundary fit is singular
anova(lag_ins_age, lag_ins_age_randslope) #fit did not improve with inclusion of random slopes
## Data: lag_dat
## Models:
## lag_ins_age: Ins_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_ins_age_randslope: Ins_conc_molal ~ mri_age_y + (1 + mri_age_y | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_ins_age 4 1011.1 1026.2 -501.57 1003.1
## lag_ins_age_randslope 6 1014.4 1037.0 -501.20 1002.4 0.7291 2 0.6945
lag_glx_age<- lmer(Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
## boundary (singular) fit: see ?isSingular
summary(lag_glx_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1382.3 1397.4 -687.2 1374.3 314
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7144 -0.6884 0.0219 0.6876 3.5966
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.00 0.0
## Residual 4.41 2.1
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 23.21510 0.38755 318.00000 59.902 < 2e-16 ***
## mri_age_y -0.25957 0.06216 318.00000 -4.176 3.84e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.953
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
#boundary fit is singular
lag_glx_age_randslope<- lmer(Glu_Gln_conc_molal ~ mri_age_y + (1 + mri_age_y | subj_id), data=lag_dat, REML=FALSE)
## boundary (singular) fit: see ?isSingular
summary(lag_glx_age_randslope)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y + (1 + mri_age_y | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1385.5 1408.1 -686.8 1373.5 312
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.6842 -0.6875 0.0304 0.6436 3.6326
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subj_id (Intercept) 1.47522 1.2146
## mri_age_y 0.04111 0.2028 -1.00
## Residual 4.26131 2.0643
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 23.15821 0.41095 78.14454 56.353 < 2e-16 ***
## mri_age_y -0.24632 0.06646 65.35412 -3.706 0.000436 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.958
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
#boundary fit is singular
anova(lag_glx_age, lag_glx_age_randslope) #fit did not improve with inclusion of random slopes
## Data: lag_dat
## Models:
## lag_glx_age: Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_glx_age_randslope: Glu_Gln_conc_molal ~ mri_age_y + (1 + mri_age_y | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_glx_age 4 1382.3 1397.4 -687.16 1374.3
## lag_glx_age_randslope 6 1385.5 1408.1 -686.76 1373.5 0.8068 2 0.668
##Tissue fraction analysis Calculate tissue fraction GM/(GM+WM) for each subject/voxel Add tissue fraction as fixed effect in lmer models ACG
library(ggplot2)
library(EnvStats)
library(lme4)
library(lmerTest)
#ACG - USE THESE MODELS!! (identified 2 subjects with poor coregistration & removed them)
#read in data
acg_dat <- read.csv("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/acg_data_molal_outliers_removed_n114.csv")
#create tissue fraction variable
acg_dat$TissueFraction_GMWM <- acg_dat$fGM/(acg_dat$fGM + acg_dat$fWM)
#plot tissue fraction to check for issues
plot_ACG_tissuefraction <- ggplot(acg_dat, aes(TissueFraction_GMWM))
plot_ACG_tissuefraction+ geom_density() #big skew
plot_ACG_tissuefraction + geom_boxplot() #4 potential outliers
rosnerTest(acg_dat$TissueFraction_GMWM, k = 4)
## $distribution
## [1] "Normal"
##
## $statistic
## R.1 R.2 R.3 R.4
## 7.321846 5.197468 3.846599 3.535743
##
## $sample.size
## [1] 114
##
## $parameters
## k
## 4
##
## $alpha
## [1] 0.05
##
## $crit.value
## lambda.1 lambda.2 lambda.3 lambda.4
## 3.428193 3.425263 3.422302 3.419309
##
## $n.outliers
## [1] 4
##
## $alternative
## [1] "Up to 4 observations are not\n from the same Distribution."
##
## $method
## [1] "Rosner's Test for Outliers"
##
## $data
## [1] 0.9390198 0.9661804 0.9655023 0.9366803 0.8741955 0.9311618 0.9320337
## [8] 0.9397518 0.9548737 0.9669866 0.9444564 0.9138117 0.9490174 0.9573432
## [15] 0.9497333 0.9748258 0.9941847 0.9486011 0.9602519 0.9612505 0.9732704
## [22] 0.9790679 0.9479635 0.8046696 0.9719504 0.9435072 0.9860912 0.9252084
## [29] 0.8946503 0.9275092 0.9413340 0.9619213 0.9344712 0.9996141 0.9611735
## [36] 0.9812598 0.6594113 0.9283294 0.9853063 0.9976770 0.9481254 0.9628117
## [43] 0.9347577 0.9444220 0.9509674 0.9248160 0.9468277 0.9750073 0.9871912
## [50] 0.9848082 0.9777584 0.9709937 0.9427788 0.9516720 0.9772194 0.8991193
## [57] 0.9724672 0.9533810 0.9848684 0.9562166 0.9898357 0.9339068 0.9541988
## [64] 0.9779450 0.9755787 0.9424898 0.9860622 0.9440049 0.9238023 0.9511135
## [71] 0.9519491 0.9895463 0.9500137 0.9847202 0.9509092 0.9630685 0.9736999
## [78] 0.9281849 0.9266655 0.9872865 0.9798646 0.9595847 0.9541502 0.9831991
## [85] 0.9377129 0.9309479 0.9847561 0.9729524 0.9754696 0.9392829 0.9671345
## [92] 0.9700358 0.8595117 0.9559970 0.9768332 0.9787093 0.9556623 0.9457820
## [99] 0.9936215 0.9881743 0.9804760 0.9764555 0.9591807 0.9290081 0.9073076
## [106] 0.9651388 0.9776632 0.9805040 0.9636278 0.9544220 0.9467918 0.9651846
## [113] 0.9882172 0.9951620
##
## $data.name
## [1] "acg_dat$TissueFraction_GMWM"
##
## $bad.obs
## [1] 0
##
## $all.stats
## i Mean.i SD.i Value Obs.Num R.i+1 lambda.i+1 Outlier
## 1 0 0.9534558 0.04015989 0.6594113 37 7.321846 3.428193 TRUE
## 2 1 0.9560580 0.02912733 0.8046696 24 5.197468 3.425263 TRUE
## 3 2 0.9574096 0.02545051 0.8595117 93 3.846599 3.422302 TRUE
## 4 3 0.9582916 0.02378455 0.8741955 5 3.535743 3.419309 TRUE
##
## attr(,"class")
## [1] "gofOutlier"
#4 outliers: Obs. Num 37 (PS14_090), 24 (PS14_050), 93 (PS18_1601), 5 (PS14_009) - double check cogregistration
#PS14_090 is shifted to the left and includes substantial WM - EXCLUDE
#PS14_050 is shifted to the left and T1 quality is poor - EXCLUDE
#PS18_1601 head tilted so voxel captures a bit of WM in the left hemi., a little anterior; doesn't seem terrible
#PS14_009 looks like chin was tipped down toward chest a bit, corner of voxel captures some CC white matter but seems ok
#exclude scans PS14_090 and PS14_050 due to outlier status coregistration issues
acg_dat_tf <- subset(acg_dat, study_code != c("PS14_090", "PS14_050"))
#save database with tissue fraction
write.csv(acg_dat_tf, "/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/acg_data_molal_outliers_removed_n112_tissuefraction.csv", row.names = FALSE)
#check correlation between tissue fraction and age
acg_TisFrac_age <- lmer(TissueFraction_GMWM ~ mri_age_y + (1 | subj_id), data=acg_dat_tf, REML=FALSE)
summary(acg_TisFrac_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: TissueFraction_GMWM ~ mri_age_y + (1 | subj_id)
## Data: acg_dat_tf
##
## AIC BIC logLik deviance df.resid
## -502.4 -491.5 255.2 -510.4 108
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.9651 -0.3154 0.0453 0.4218 1.8581
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.0004953 0.02225
## Residual 0.0001780 0.01334
## Number of obs: 112, groups: subj_id, 101
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 9.536e-01 8.865e-03 1.008e+02 107.58 <2e-16 ***
## mri_age_y 8.646e-04 2.061e-03 9.620e+01 0.42 0.676
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.957
#not sig.
#Add tissue fraction as fixed effect in ACG models
#NAA
#basic age model
acg_naa_age <- lmer(NAA_conc_molal ~ mri_age_y + (1 | subj_id), data=acg_dat_tf, REML=FALSE)
summary(acg_naa_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: NAA_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: acg_dat_tf
##
## AIC BIC logLik deviance df.resid
## 367.1 377.9 -179.5 359.1 108
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.7946 -0.4453 0.0368 0.4273 1.8841
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.8884 0.9426
## Residual 0.6342 0.7964
## Number of obs: 112, groups: subj_id, 101
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 14.0555 0.4360 110.0242 32.234 <2e-16 ***
## mri_age_y 0.2170 0.1018 107.9217 2.132 0.0352 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.960
#add tissue fraction
acg_naa_age_tf <- lmer(NAA_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id), data=acg_dat_tf, REML=FALSE)
summary(acg_naa_age_tf) #no sig. effect of tissue fraction
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: NAA_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## Data: acg_dat_tf
##
## AIC BIC logLik deviance df.resid
## 369.0 382.5 -179.5 359.0 107
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.79030 -0.43643 0.02214 0.42239 1.82887
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.9093 0.9536
## Residual 0.6159 0.7848
## Number of obs: 112, groups: subj_id, 101
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 12.6290 4.3832 111.3683 2.881 0.00475 **
## mri_age_y 0.2173 0.1017 107.5102 2.137 0.03484 *
## TissueFraction_GMWM 1.4890 4.5670 110.8943 0.326 0.74501
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.072
## TssFrc_GMWM -0.995 -0.024
#compare models
anova(acg_naa_age, acg_naa_age_tf) #model fit not sig. different
## Data: acg_dat_tf
## Models:
## acg_naa_age: NAA_conc_molal ~ mri_age_y + (1 | subj_id)
## acg_naa_age_tf: NAA_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## acg_naa_age 4 367.05 377.93 -179.53 359.05
## acg_naa_age_tf 5 368.95 382.54 -179.48 358.95 0.1024 1 0.749
#Cre
#basic age model
acg_cre_age <- lmer(Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id), data=acg_dat_tf, REML=FALSE)
summary(acg_cre_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: acg_dat_tf
##
## AIC BIC logLik deviance df.resid
## 326.5 337.4 -159.2 318.5 108
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.03244 -0.43490 0.00667 0.41662 1.83505
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.5316 0.7291
## Residual 0.5143 0.7171
## Number of obs: 112, groups: subj_id, 101
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 11.86301 0.36462 111.30573 32.535 <2e-16 ***
## mri_age_y 0.05596 0.08521 109.65603 0.657 0.513
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.961
#add tissue fraction
acg_cre_age_tf <- lmer(Cre_PCr_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id), data=acg_dat_tf, REML=FALSE)
summary(acg_cre_age_tf)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cre_PCr_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## Data: acg_dat_tf
##
## AIC BIC logLik deviance df.resid
## 327.7 341.3 -158.9 317.7 107
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.0818 -0.4229 0.0093 0.4170 1.8154
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.5138 0.7168
## Residual 0.5231 0.7233
## Number of obs: 112, groups: subj_id, 101
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 14.97264 3.63655 110.21630 4.117 7.43e-05 ***
## mri_age_y 0.05641 0.08499 110.00418 0.664 0.508
## TissueFraction_GMWM -3.25093 3.78651 109.54628 -0.859 0.392
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.079
## TssFrc_GMWM -0.995 -0.017
#compare models
anova(acg_cre_age, acg_cre_age_tf)
## Data: acg_dat_tf
## Models:
## acg_cre_age: Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id)
## acg_cre_age_tf: Cre_PCr_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## acg_cre_age 4 326.48 337.35 -159.24 318.48
## acg_cre_age_tf 5 327.75 341.34 -158.87 317.75 0.7326 1 0.392
#Cho
#basic age model
acg_cho_age <- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id), data=acg_dat_tf, REML=FALSE)
summary(acg_cho_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: acg_dat_tf
##
## AIC BIC logLik deviance df.resid
## 71.8 82.7 -31.9 63.8 107
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.2196 -0.6351 -0.1422 0.6260 2.4985
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.02885 0.1698
## Residual 0.07645 0.2765
## Number of obs: 111, groups: subj_id, 100
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.76627 0.11750 110.84406 23.542 <2e-16 ***
## mri_age_y -0.06757 0.02753 110.97978 -2.454 0.0157 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.963
#add tissue fraction
acg_cho_age_tf <- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id), data=acg_dat_tf, REML=FALSE)
summary(acg_cho_age_tf)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cho_GPC_PCh_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 |
## subj_id)
## Data: acg_dat_tf
##
## AIC BIC logLik deviance df.resid
## 72.4 86.0 -31.2 62.4 106
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.2749 -0.6003 -0.1319 0.6231 2.5882
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.02741 0.1656
## Residual 0.07649 0.2766
## Number of obs: 111, groups: subj_id, 100
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 4.13279 1.15856 110.21040 3.567 0.000535 ***
## mri_age_y -0.06723 0.02736 110.98803 -2.457 0.015546 *
## TissueFraction_GMWM -1.42905 1.20549 110.05170 -1.185 0.238392
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.087
## TssFrc_GMWM -0.995 -0.010
#compare models
anova(acg_cho_age, acg_cho_age_tf) #fit not significantly different
## Data: acg_dat_tf
## Models:
## acg_cho_age: Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id)
## acg_cho_age_tf: Cho_GPC_PCh_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## acg_cho_age 4 71.815 82.653 -31.907 63.815
## acg_cho_age_tf 5 72.421 85.968 -31.210 62.421 1.3941 1 0.2377
#Ins
#basic age model
acg_ins_age <- lmer(Ins_conc_molal ~ mri_age_y + (1 | subj_id), data=acg_dat_tf, REML=FALSE)
summary(acg_ins_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: acg_dat_tf
##
## AIC BIC logLik deviance df.resid
## 410.8 421.7 -201.4 402.8 107
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.52173 -0.46069 0.06961 0.51164 1.58802
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.9207 0.9596
## Residual 1.3419 1.1584
## Number of obs: 111, groups: subj_id, 100
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 8.6315 0.5425 110.9914 15.909 <2e-16 ***
## mri_age_y -0.2375 0.1274 110.5660 -1.864 0.065 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.962
#add tissue fraction
acg_ins_age_tf <- lmer(Ins_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id), data=acg_dat_tf, REML=FALSE)
summary(acg_ins_age_tf)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## Data: acg_dat_tf
##
## AIC BIC logLik deviance df.resid
## 412.5 426.0 -201.2 402.5 106
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.5179 -0.4921 0.0842 0.5642 1.5151
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.9385 0.9688
## Residual 1.3192 1.1486
## Number of obs: 111, groups: subj_id, 100
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 5.3956 5.4120 109.7617 0.997 0.3210
## mri_age_y -0.2384 0.1272 110.5187 -1.875 0.0634 .
## TissueFraction_GMWM 3.3859 5.6286 109.3900 0.602 0.5487
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.094
## TssFrc_GMWM -0.995 -0.002
#compare models
anova(acg_ins_age,acg_ins_age_tf) #not sig.
## Data: acg_dat_tf
## Models:
## acg_ins_age: Ins_conc_molal ~ mri_age_y + (1 | subj_id)
## acg_ins_age_tf: Ins_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## acg_ins_age 4 410.83 421.66 -201.41 402.83
## acg_ins_age_tf 5 412.47 426.01 -201.23 402.47 0.3599 1 0.5485
#Glx
#basic age model
acg_glx_age <- lmer(Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id), data=acg_dat_tf, REML=FALSE)
summary(acg_glx_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: acg_dat_tf
##
## AIC BIC logLik deviance df.resid
## 534.2 545.1 -263.1 526.2 108
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.48962 -0.37028 0.00319 0.44161 1.70136
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 4.551 2.133
## Residual 2.340 1.530
## Number of obs: 112, groups: subj_id, 101
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 25.8899 0.9153 106.7469 28.29 <2e-16 ***
## mri_age_y 0.2432 0.2133 103.5166 1.14 0.257
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.959
#add tissue fraction
acg_glx_age_tf <- lmer(Glu_Gln_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id), data=acg_dat_tf, REML=FALSE)
summary(acg_glx_age_tf)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## Data: acg_dat_tf
##
## AIC BIC logLik deviance df.resid
## 534.3 547.9 -262.1 524.3 107
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.42997 -0.35041 -0.02915 0.40797 1.50666
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 4.782 2.187
## Residual 2.062 1.436
## Number of obs: 112, groups: subj_id, 101
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 12.9044 9.1846 111.9973 1.405 0.163
## mri_age_y 0.2368 0.2105 100.6186 1.125 0.263
## TissueFraction_GMWM 13.5939 9.5797 111.8624 1.419 0.159
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.060
## TssFrc_GMWM -0.995 -0.034
##Plot ACG results with 2 tissue fraction outlier subjects excluded Plotting simple age models run with N=112 subjects
#NAA
#pull fixed effects
fixef.acg_naa<-fixef(acg_naa_age)
plot_acg_naa_age<-ggplot(acg_dat_tf, aes(x=mri_age_y, y=NAA_conc_molal,color=as.factor(female))) +
geom_point() +
labs(title = "Anterior Cingulate", x = "Age (years)", y = "tNAA (molal)") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_smooth(method = "lm", se = FALSE, aes(x=mri_age_y, y=NAA_conc_molal, group=as.factor(subj_id)), size = .3, show.legend = FALSE) +
geom_abline(aes(intercept = fixef.acg_naa[[1]], slope= fixef.acg_naa[[2]])) +
theme_classic()
plot_acg_naa_age
## `geom_smooth()` using formula 'y ~ x'
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/acg_naa_age_viridis_n112.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
#Cho
#pull intercept and slope from model for regression line
fixef.acg_cho<-fixef(acg_cho_age)
#plot
plot_acg_cho_age<-ggplot(acg_dat_tf, aes(x=mri_age_y, y=Cho_GPC_PCh_conc_molal,color=as.factor(female))) +
geom_point() +
labs(title = "Anterior Cingulate", x = "Age (years)", y = "tCho (molal)") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_smooth(method = "lm", se = FALSE, aes(x=mri_age_y, y=Cho_GPC_PCh_conc_molal, group=as.factor(subj_id)), size = .3, show.legend = FALSE) +
geom_abline(aes(intercept = fixef.acg_cho[[1]], slope= fixef.acg_cho[[2]])) +
theme_classic()
plot_acg_cho_age
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/acg_cho_age_viridis_n112.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
#Ins
#pull intercept and slope from model for regression line
fixef.acg_ins<-fixef(acg_ins_age)
#plot
plot_acg_ins_age<-ggplot(acg_dat_tf, aes(x=mri_age_y, y=Ins_conc_molal,color=as.factor(female))) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, aes(x=mri_age_y, y=Ins_conc_molal, group=as.factor(subj_id)), size = .3, show.legend = FALSE) +
labs(title = "Anterior Cingulate", x = "Age (years)", y = "Ins (molal)") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_abline(aes(intercept = fixef.acg_ins[[1]], slope= fixef.acg_ins[[2]])) +
theme_classic()
plot_acg_ins_age
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/acg_ins_age_viridis_n112.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
LAG Tissue Fraction models
#LAG
#read in data
lag_dat<-read.csv("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/lag_data_molal_outliers_removed_n319.csv")
#create tissue fraction variable
lag_dat$TissueFraction_GMWM <- lag_dat$fGM/(lag_dat$fGM + lag_dat$fWM)
#plot tissue fraction to check for issues
plot_LAG_tissuefraction <- ggplot(lag_dat, aes(TissueFraction_GMWM))
plot_LAG_tissuefraction+ geom_density() #normal
plot_LAG_tissuefraction + geom_boxplot() #6 potential outliers
rosnerTest(lag_dat$TissueFraction_GMWM, k = 6) #no significant outliers
## $distribution
## [1] "Normal"
##
## $statistic
## R.1 R.2 R.3 R.4 R.5 R.6
## 3.072952 2.983269 2.933378 2.962159 2.930951 2.723514
##
## $sample.size
## [1] 319
##
## $parameters
## k
## 6
##
## $alpha
## [1] 0.05
##
## $crit.value
## lambda.1 lambda.2 lambda.3 lambda.4 lambda.5 lambda.6
## 3.740829 3.739949 3.739067 3.738181 3.737291 3.736399
##
## $n.outliers
## [1] 0
##
## $alternative
## [1] "Up to 6 observations are not\n from the same Distribution."
##
## $method
## [1] "Rosner's Test for Outliers"
##
## $data
## [1] 0.7657305 0.6515751 0.5744539 0.6894155 0.8381194 0.5951315 0.7008113
## [8] 0.6813746 0.5352570 0.6558286 0.7097519 0.7819635 0.7021001 0.7039674
## [15] 0.4764324 0.6028844 0.6327450 0.6087942 0.6968812 0.8026664 0.7009372
## [22] 0.7208761 0.6605230 0.7324027 0.5453879 0.7620629 0.6701616 0.6375845
## [29] 0.5632865 0.6708753 0.6927008 0.7798970 0.7618192 0.6477681 0.6613518
## [36] 0.5340622 0.5942859 0.6943742 0.7009750 0.5879671 0.4411657 0.6156132
## [43] 0.6142354 0.7259517 0.5979064 0.5685179 0.5271897 0.5355836 0.7237169
## [50] 0.7571831 0.5285119 0.6751229 0.5119628 0.7521085 0.6615893 0.5425676
## [57] 0.6627217 0.6549878 0.7279301 0.7256598 0.7477565 0.6395054 0.7213695
## [64] 0.7384663 0.7633997 0.7529087 0.8002460 0.8145222 0.7366533 0.7977780
## [71] 0.6151766 0.7154834 0.7754343 0.8142228 0.7207045 0.6896770 0.5855033
## [78] 0.4519376 0.3757102 0.6561017 0.7878613 0.7377081 0.8047878 0.7816798
## [85] 0.8279033 0.6753913 0.7666730 0.5795116 0.7313181 0.6599876 0.7201454
## [92] 0.6696166 0.5834821 0.6485976 0.5740399 0.7069867 0.7142496 0.6394643
## [99] 0.7231628 0.6282001 0.7420446 0.5742007 0.7048192 0.8067634 0.8402937
## [106] 0.6709200 0.7285484 0.6456249 0.7123905 0.7182381 0.6336725 0.7074584
## [113] 0.5114034 0.7548622 0.7512744 0.6852121 0.6741392 0.4619200 0.5944252
## [120] 0.6890812 0.5371624 0.6516809 0.6145975 0.6753211 0.5748713 0.7172832
## [127] 0.7275696 0.4961396 0.6162007 0.4003669 0.6812224 0.6283159 0.6387185
## [134] 0.7522739 0.4447576 0.5459764 0.5522673 0.5951632 0.5682089 0.5371529
## [141] 0.6615547 0.6791234 0.7036370 0.6886679 0.6631862 0.6341630 0.6738518
## [148] 0.7549798 0.6955773 0.6542445 0.6925320 0.6505739 0.6425831 0.6677008
## [155] 0.7839529 0.6553603 0.5432005 0.6122120 0.6548850 0.6367154 0.7679106
## [162] 0.7485923 0.7184663 0.6312047 0.7349290 0.7043475 0.4988189 0.8401854
## [169] 0.6577281 0.8438765 0.8390803 0.6282136 0.6405363 0.7191654 0.6334385
## [176] 0.7081752 0.6659769 0.6107064 0.6347357 0.7290806 0.7344315 0.6660147
## [183] 0.6251258 0.5997631 0.5785047 0.7984798 0.5070360 0.6098369 0.6299690
## [190] 0.6516707 0.5494253 0.6308773 0.7664214 0.5915382 0.5878598 0.8187175
## [197] 0.6741752 0.7564550 0.6443908 0.7395504 0.5204329 0.6170451 0.7002564
## [204] 0.6246470 0.6681476 0.5771348 0.7295070 0.7423764 0.6384295 0.5430082
## [211] 0.6707773 0.6881614 0.7608897 0.5543782 0.6804216 0.5896538 0.6427618
## [218] 0.6536086 0.7261262 0.6317773 0.6652328 0.6605223 0.5295042 0.6174694
## [225] 0.6425888 0.5149187 0.7329097 0.5653457 0.5104815 0.6635529 0.7475020
## [232] 0.7604907 0.6907149 0.5576525 0.6882708 0.7095940 0.5975811 0.6217704
## [239] 0.6017863 0.6938276 0.4639501 0.7554426 0.5394351 0.5730658 0.5198421
## [246] 0.6217217 0.5560520 0.7715035 0.7450276 0.7578195 0.7198068 0.6385403
## [253] 0.4769133 0.6216745 0.7215428 0.7135267 0.5015701 0.5463705 0.3420581
## [260] 0.4840778 0.4052625 0.3302661 0.3499400 0.6039142 0.4129804 0.5315517
## [267] 0.5809198 0.4792521 0.5046752 0.5684662 0.5218814 0.3154764 0.3403429
## [274] 0.5024469 0.3751392 0.6127580 0.7315085 0.4137321 0.4513800 0.5718875
## [281] 0.7465811 0.5551458 0.4922670 0.5978026 0.6036407 0.7885750 0.7143374
## [288] 0.5734673 0.7879821 0.5626092 0.6622175 0.4524319 0.4110109 0.6597638
## [295] 0.5684290 0.4234816 0.4456416 0.5029994 0.5793653 0.6290320 0.4115474
## [302] 0.6699743 0.7957488 0.7141763 0.7477478 0.5862060 0.7635972 0.7800932
## [309] 0.5786560 0.5839172 0.6023700 0.5311156 0.5390859 0.6565085 0.8540765
## [316] 0.7585903 0.5580707 0.6451797 0.4621925
##
## $data.name
## [1] "lag_dat$TissueFraction_GMWM"
##
## $bad.obs
## [1] 0
##
## $all.stats
## i Mean.i SD.i Value Obs.Num R.i+1 lambda.i+1 Outlier
## 1 0 0.6413041 0.10603083 0.3154764 272 3.072952 3.740829 FALSE
## 2 1 0.6423287 0.10460424 0.3302661 262 2.983269 3.739949 FALSE
## 3 2 0.6433131 0.10328372 0.3403429 273 2.933378 3.739067 FALSE
## 4 3 0.6442719 0.10202485 0.3420581 259 2.962159 3.738181 FALSE
## 5 4 0.6452313 0.10074933 0.3499400 263 2.930951 3.737291 FALSE
## 6 5 0.6461717 0.09951575 0.3751392 275 2.723514 3.736399 FALSE
##
## attr(,"class")
## [1] "gofOutlier"
write.csv(lag_dat, "/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/lag_data_molal_outliers_removed_n319_tissuefraction.csv")
#check correlation between tissue fraction and age
lag_TisFrac_age <- lmer(TissueFraction_GMWM ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_TisFrac_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: TissueFraction_GMWM ~ mri_age_y + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## -571.4 -556.3 289.7 -579.4 315
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.81543 -0.62516 0.04728 0.70038 2.05231
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.0008379 0.02895
## Residual 0.0087943 0.09378
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.769451 0.018203 303.261530 42.271 < 2e-16 ***
## mri_age_y -0.021693 0.002872 318.999803 -7.553 4.52e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.940
#tissue fraction is significantly negatively associated with age
#in a simple correlation test
cor.test(lag_dat$mri_age_y, lag_dat$TissueFraction_GMWM) #r = -.38
##
## Pearson's product-moment correlation
##
## data: lag_dat$mri_age_y and lag_dat$TissueFraction_GMWM
## t = -7.2359, df = 317, p-value = 3.505e-12
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.4670082 -0.2781944
## sample estimates:
## cor
## -0.3765045
#Add tissue fraction as a fixed effect in LAG models
#basic age model NAA
lag_naa_age<- lmer(NAA_conc_molal ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
#add tissue fraction
lag_naa_age_TisFrac <- lmer(NAA_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_naa_age_TisFrac)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: NAA_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 855.9 874.7 -423.0 845.9 312
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.9760 -0.5775 -0.0185 0.5568 3.9394
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1614 0.4017
## Residual 0.7209 0.8491
## Number of obs: 317, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 11.27969 0.44221 316.99130 25.508 < 2e-16 ***
## mri_age_y 0.17139 0.02968 316.93976 5.775 1.84e-08 ***
## TissueFraction_GMWM 3.27768 0.52579 314.11297 6.234 1.46e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.700
## TssFrc_GMWM -0.918 0.395
#compare model fit
anova(lag_naa_age, lag_naa_age_TisFrac) #fit significantly improved
## Data: lag_dat
## Models:
## lag_naa_age: NAA_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_naa_age_TisFrac: NAA_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_naa_age 4 890.46 905.50 -441.23 882.46
## lag_naa_age_TisFrac 5 855.92 874.71 -422.96 845.92 36.547 1 1.491e-09
##
## lag_naa_age
## lag_naa_age_TisFrac ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#add tissue fraction interaction with age
lag_naa_age_TisFracXage <- lmer(NAA_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_naa_age_TisFracXage)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: NAA_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 855.3 877.8 -421.6 843.3 311
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.1398 -0.5499 -0.0438 0.5462 4.0012
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1586 0.3982
## Residual 0.7158 0.8460
## Number of obs: 317, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 9.8449 0.9840 311.8856 10.005 < 2e-16 ***
## mri_age_y 0.3862 0.1350 305.9822 2.861 0.004514 **
## TissueFraction_GMWM 5.6231 1.5309 310.1123 3.673 0.000282 ***
## mri_age_y:TissueFraction_GMWM -0.3595 0.2205 304.4046 -1.631 0.103985
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y TF_GMW
## mri_age_y -0.941
## TssFrc_GMWM -0.981 0.946
## m__:TF_GMWM 0.894 -0.976 -0.940
#interaction term for agexTissueFraction not sig.
#compare model fit
anova(lag_naa_age_TisFrac, lag_naa_age_TisFracXage) #not sig., stick with age + TissueFraction model
## Data: lag_dat
## Models:
## lag_naa_age_TisFrac: NAA_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## lag_naa_age_TisFracXage: NAA_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df
## lag_naa_age_TisFrac 5 855.92 874.71 -422.96 845.92
## lag_naa_age_TisFracXage 6 855.27 877.82 -421.63 843.27 2.6473 1
## Pr(>Chisq)
## lag_naa_age_TisFrac
## lag_naa_age_TisFracXage 0.1037
#add sex to tissue fraction model
lag_naa_age_TisFrac_sex <- lmer(NAA_conc_molal ~ mri_age_y + TissueFraction_GMWM + female + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_naa_age_TisFrac_sex) #sex not significant
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: NAA_conc_molal ~ mri_age_y + TissueFraction_GMWM + female + (1 |
## subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 857.8 880.4 -422.9 845.8 311
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.9680 -0.5692 -0.0143 0.5672 3.9278
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1602 0.4003
## Residual 0.7214 0.8494
## Number of obs: 317, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 11.28975 0.44367 316.94763 25.446 < 2e-16 ***
## mri_age_y 0.17185 0.02972 316.96281 5.782 1.77e-08 ***
## TissueFraction_GMWM 3.28435 0.52641 314.17936 6.239 1.42e-09 ***
## female -0.03591 0.13195 97.90588 -0.272 0.786
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y TF_GMW
## mri_age_y -0.692
## TssFrc_GMWM -0.910 0.396
## female -0.082 -0.055 -0.049
#compare model fit
anova(lag_naa_age_TisFrac, lag_naa_age_TisFrac_sex) #not sig., stick with age + TissueFraction model
## Data: lag_dat
## Models:
## lag_naa_age_TisFrac: NAA_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## lag_naa_age_TisFrac_sex: NAA_conc_molal ~ mri_age_y + TissueFraction_GMWM + female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df
## lag_naa_age_TisFrac 5 855.92 874.71 -422.96 845.92
## lag_naa_age_TisFrac_sex 6 857.84 880.40 -422.92 845.84 0.0736 1
## Pr(>Chisq)
## lag_naa_age_TisFrac
## lag_naa_age_TisFrac_sex 0.7862
#Cre
#basic age model
lag_cre_age<- lmer(Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cre_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 842.9 858.0 -417.4 834.9 315
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.9830 -0.5313 -0.1227 0.5456 4.1744
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.08589 0.2931
## Residual 0.72923 0.8539
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 10.48668 0.16753 306.60267 62.598 <2e-16 ***
## mri_age_y -0.04066 0.02635 318.92136 -1.543 0.124
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.937
#add tissue fraction
lag_cre_age_TisFrac<- lmer(Cre_PCr_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cre_age_TisFrac)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cre_PCr_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 758.9 777.7 -374.4 748.9 314
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7436 -0.5047 0.0268 0.4405 4.8766
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.08544 0.2923
## Residual 0.54309 0.7369
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 7.05033 0.37589 318.62021 18.756 <2e-16 ***
## mri_age_y 0.05654 0.02505 318.77753 2.257 0.0247 *
## TissueFraction_GMWM 4.46604 0.44851 318.00128 9.957 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.699
## TssFrc_GMWM -0.920 0.395
#compare model fit
anova(lag_cre_age, lag_cre_age_TisFrac) #sig. best model is lag_cre_age_TisFrac
## Data: lag_dat
## Models:
## lag_cre_age: Cre_PCr_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_cre_age_TisFrac: Cre_PCr_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_cre_age 4 842.89 857.95 -417.45 834.89
## lag_cre_age_TisFrac 5 758.87 777.70 -374.44 748.87 86.018 1 < 2.2e-16
##
## lag_cre_age
## lag_cre_age_TisFrac ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#add interaction
lag_cre_age_TisFrac_int<- lmer(Cre_PCr_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cre_age_TisFrac_int)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cre_PCr_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 760.6 783.2 -374.3 748.6 313
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7303 -0.5036 0.0285 0.4515 4.8936
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.08461 0.2909
## Residual 0.54313 0.7370
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 6.65720 0.83989 316.14192 7.926 3.91e-14
## mri_age_y 0.11561 0.11554 311.21102 1.001 0.317791
## TissueFraction_GMWM 5.10801 1.30608 314.73791 3.911 0.000113
## mri_age_y:TissueFraction_GMWM -0.09881 0.18868 309.73015 -0.524 0.600859
##
## (Intercept) ***
## mri_age_y
## TissueFraction_GMWM ***
## mri_age_y:TissueFraction_GMWM
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y TF_GMW
## mri_age_y -0.941
## TssFrc_GMWM -0.981 0.946
## m__:TF_GMWM 0.894 -0.976 -0.939
#compare model fit
anova(lag_cre_age_TisFrac, lag_cre_age_TisFrac_int) #not sig.
## Data: lag_dat
## Models:
## lag_cre_age_TisFrac: Cre_PCr_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## lag_cre_age_TisFrac_int: Cre_PCr_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df
## lag_cre_age_TisFrac 5 758.87 777.70 -374.44 748.87
## lag_cre_age_TisFrac_int 6 760.60 783.19 -374.30 748.60 0.2737 1
## Pr(>Chisq)
## lag_cre_age_TisFrac
## lag_cre_age_TisFrac_int 0.6009
#add sex to tissue fraction model
lag_cre_age_TisFrac_sex<- lmer(Cre_PCr_conc_molal ~ mri_age_y + TissueFraction_GMWM + female + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cre_age_TisFrac_sex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cre_PCr_conc_molal ~ mri_age_y + TissueFraction_GMWM + female +
## (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 760.7 783.3 -374.3 748.7 313
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7624 -0.5130 0.0184 0.4556 4.8990
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.08513 0.2918
## Residual 0.54293 0.7368
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 7.03804 0.37683 318.21172 18.677 <2e-16 ***
## mri_age_y 0.05590 0.02509 318.74267 2.228 0.0266 *
## TissueFraction_GMWM 4.45651 0.44889 318.04852 9.928 <2e-16 ***
## female 0.04684 0.10653 90.94087 0.440 0.6612
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y TF_GMW
## mri_age_y -0.691
## TssFrc_GMWM -0.913 0.397
## female -0.075 -0.058 -0.047
#compare model fit
anova(lag_cre_age_TisFrac, lag_cre_age_TisFrac_sex) #not sig.
## Data: lag_dat
## Models:
## lag_cre_age_TisFrac: Cre_PCr_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## lag_cre_age_TisFrac_sex: Cre_PCr_conc_molal ~ mri_age_y + TissueFraction_GMWM + female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df
## lag_cre_age_TisFrac 5 758.87 777.70 -374.44 748.87
## lag_cre_age_TisFrac_sex 6 760.68 783.27 -374.34 748.68 0.1932 1
## Pr(>Chisq)
## lag_cre_age_TisFrac
## lag_cre_age_TisFrac_sex 0.6602
#Cho
#basic age model
lag_cho_age<- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cho_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 51.3 66.4 -21.7 43.3 315
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.6543 -0.5762 -0.0565 0.4634 4.1262
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.01502 0.1225
## Residual 0.05605 0.2367
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.344024 0.049129 308.131799 47.711 < 2e-16 ***
## mri_age_y -0.023002 0.007589 315.366670 -3.031 0.00264 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.921
#add tissue fraction
lag_cho_age_TisFrac<- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cho_age_TisFrac)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cho_GPC_PCh_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 |
## subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 21.3 40.2 -5.7 11.3 314
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.5647 -0.6246 -0.0387 0.5017 4.7463
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.01233 0.1110
## Residual 0.05140 0.2267
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.976013 0.118352 318.903872 25.146 < 2e-16 ***
## mri_age_y -0.041332 0.007886 318.814680 -5.241 2.91e-07 ***
## TissueFraction_GMWM -0.817191 0.140666 313.971075 -5.809 1.54e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.702
## TssFrc_GMWM -0.919 0.401
#compare model fit
anova(lag_cho_age, lag_cho_age_TisFrac) #sig
## Data: lag_dat
## Models:
## lag_cho_age: Cho_GPC_PCh_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_cho_age_TisFrac: Cho_GPC_PCh_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_cho_age 4 51.328 66.388 -21.6638 43.328
## lag_cho_age_TisFrac 5 21.327 40.153 -5.6634 11.327 32.001 1 1.541e-08
##
## lag_cho_age
## lag_cho_age_TisFrac ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#add interaction
lag_cho_age_TisFrac_int<- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cho_age_TisFrac_int) #interaction is sig. (p=.047)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cho_GPC_PCh_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 |
## subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 19.4 42.0 -3.7 7.4 313
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.5433 -0.6283 -0.0528 0.4926 4.5229
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.01209 0.1100
## Residual 0.05082 0.2254
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.50966 0.26145 309.45711 9.599 <2e-16
## mri_age_y 0.02861 0.03588 301.15695 0.798 0.4257
## TissueFraction_GMWM -0.05546 0.40621 306.63258 -0.137 0.8915
## mri_age_y:TissueFraction_GMWM -0.11698 0.05855 299.02369 -1.998 0.0466
##
## (Intercept) ***
## mri_age_y
## TissueFraction_GMWM
## mri_age_y:TissueFraction_GMWM *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y TF_GMW
## mri_age_y -0.940
## TssFrc_GMWM -0.981 0.946
## m__:TF_GMWM 0.893 -0.976 -0.939
#compare model fit
anova(lag_cho_age_TisFrac, lag_cho_age_TisFrac_int) #sig. (p<.046)
## Data: lag_dat
## Models:
## lag_cho_age_TisFrac: Cho_GPC_PCh_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## lag_cho_age_TisFrac_int: Cho_GPC_PCh_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df
## lag_cho_age_TisFrac 5 21.327 40.153 -5.6634 11.3268
## lag_cho_age_TisFrac_int 6 19.360 41.952 -3.6803 7.3605 3.9662 1
## Pr(>Chisq)
## lag_cho_age_TisFrac
## lag_cho_age_TisFrac_int 0.04642 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#add sex to model
lag_cho_age_TisFrac_int_sex<- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y * TissueFraction_GMWM + female + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cho_age_TisFrac_int_sex) #not sig.
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cho_GPC_PCh_conc_molal ~ mri_age_y * TissueFraction_GMWM + female +
## (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 20.4 46.8 -3.2 6.4 312
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.5772 -0.6082 -0.0616 0.4827 4.5649
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.01201 0.1096
## Residual 0.05070 0.2252
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.53318 0.26225 310.08839 9.659 <2e-16
## mri_age_y 0.02696 0.03587 300.77834 0.752 0.4529
## TissueFraction_GMWM -0.07207 0.40603 306.38585 -0.178 0.8592
## female -0.03398 0.03554 78.06759 -0.956 0.3419
## mri_age_y:TissueFraction_GMWM -0.11346 0.05859 298.50872 -1.936 0.0538
##
## (Intercept) ***
## mri_age_y
## TissueFraction_GMWM
## female
## mri_age_y:TissueFraction_GMWM .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y TF_GMW female
## mri_age_y -0.940
## TssFrc_GMWM -0.980 0.946
## female -0.094 0.049 0.043
## m__:TF_GMWM 0.893 -0.976 -0.939 -0.063
#compare model fit
anova(lag_cho_age_TisFrac_int, lag_cho_age_TisFrac_int_sex) #not sig.
## Data: lag_dat
## Models:
## lag_cho_age_TisFrac_int: Cho_GPC_PCh_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id)
## lag_cho_age_TisFrac_int_sex: Cho_GPC_PCh_conc_molal ~ mri_age_y * TissueFraction_GMWM + female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df
## lag_cho_age_TisFrac_int 6 19.360 41.952 -3.6803 7.3605
## lag_cho_age_TisFrac_int_sex 7 20.448 46.804 -3.2238 6.4476 0.913 1
## Pr(>Chisq)
## lag_cho_age_TisFrac_int
## lag_cho_age_TisFrac_int_sex 0.3393
#Ins
#basic age model
lag_ins_age<- lmer(Ins_conc_molal ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_ins_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1011.1 1026.2 -501.6 1003.1 314
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.3931 -0.5604 -0.0184 0.5920 4.6446
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1771 0.4208
## Residual 1.2267 1.1076
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 6.28387 0.21993 305.18747 28.573 <2e-16 ***
## mri_age_y 0.01641 0.03450 317.63548 0.476 0.635
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.934
#add tissue fraction
lag_ins_age_TisFrac<- lmer(Ins_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_ins_age_TisFrac) #tissue fraction sig.; age not sig.
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1003.0 1021.8 -496.5 993.0 313
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.3833 -0.5685 -0.0316 0.5878 4.7154
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1551 0.3939
## Residual 1.1996 1.0953
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 4.64612 0.55386 316.97753 8.389 1.64e-15 ***
## mri_age_y 0.06279 0.03695 317.29527 1.699 0.09026 .
## TissueFraction_GMWM 2.12745 0.66160 317.54672 3.216 0.00144 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.698
## TssFrc_GMWM -0.921 0.394
#compare model fit
anova(lag_ins_age, lag_ins_age_TisFrac) #sig.
## Data: lag_dat
## Models:
## lag_ins_age: Ins_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_ins_age_TisFrac: Ins_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_ins_age 4 1011.1 1026.2 -501.57 1003.1
## lag_ins_age_TisFrac 5 1003.0 1021.8 -496.50 993.0 10.132 1 0.001457 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#add interaction
lag_ins_age_TisFrac_int<- lmer(Ins_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_ins_age_TisFrac_int) #tissue fraction, age & interaction all sig.
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 999.1 1021.7 -493.6 987.1 312
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.3920 -0.5998 0.0019 0.5704 4.7105
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1743 0.4175
## Residual 1.1625 1.0782
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.9626 1.2270 314.8718 1.599 0.110715
## mri_age_y 0.4673 0.1688 309.0840 2.768 0.005987 **
## TissueFraction_GMWM 6.5078 1.9084 313.2225 3.410 0.000735 ***
## mri_age_y:TissueFraction_GMWM -0.6761 0.2758 307.1983 -2.451 0.014794 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y TF_GMW
## mri_age_y -0.941
## TssFrc_GMWM -0.981 0.946
## m__:TF_GMWM 0.894 -0.976 -0.939
#compare model fit
anova(lag_ins_age_TisFrac, lag_ins_age_TisFrac_int) #sig.
## Data: lag_dat
## Models:
## lag_ins_age_TisFrac: Ins_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## lag_ins_age_TisFrac_int: Ins_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df
## lag_ins_age_TisFrac 5 1003.00 1021.8 -496.50 993.00
## lag_ins_age_TisFrac_int 6 999.13 1021.7 -493.56 987.13 5.8735 1
## Pr(>Chisq)
## lag_ins_age_TisFrac
## lag_ins_age_TisFrac_int 0.01537 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#add sex
lag_ins_age_TisFrac_int_sex<- lmer(Ins_conc_molal ~ mri_age_y * TissueFraction_GMWM + female + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_ins_age_TisFrac_int_sex) #tissue fraction, age & interaction all sig.
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y * TissueFraction_GMWM + female + (1 |
## subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1001.1 1027.5 -493.6 987.1 311
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.3921 -0.5997 0.0019 0.5705 4.7105
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1743 0.4175
## Residual 1.1625 1.0782
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.963e+00 1.232e+00 3.150e+02 1.593 0.112208
## mri_age_y 4.673e-01 1.691e-01 3.084e+02 2.764 0.006058
## TissueFraction_GMWM 6.508e+00 1.910e+00 3.128e+02 3.406 0.000745
## female -2.215e-04 1.551e-01 7.834e+01 -0.001 0.998864
## mri_age_y:TissueFraction_GMWM -6.761e-01 2.765e-01 3.064e+02 -2.446 0.015026
##
## (Intercept)
## mri_age_y **
## TissueFraction_GMWM ***
## female
## mri_age_y:TissueFraction_GMWM *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y TF_GMW female
## mri_age_y -0.940
## TssFrc_GMWM -0.980 0.946
## female -0.092 0.053 0.046
## m__:TF_GMWM 0.895 -0.976 -0.939 -0.067
#compare model fit
anova(lag_ins_age_TisFrac_int, lag_ins_age_TisFrac_int_sex) #not sig.
## Data: lag_dat
## Models:
## lag_ins_age_TisFrac_int: Ins_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id)
## lag_ins_age_TisFrac_int_sex: Ins_conc_molal ~ mri_age_y * TissueFraction_GMWM + female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df
## lag_ins_age_TisFrac_int 6 999.13 1021.7 -493.56 987.13
## lag_ins_age_TisFrac_int_sex 7 1001.13 1027.5 -493.56 987.13 0 1
## Pr(>Chisq)
## lag_ins_age_TisFrac_int
## lag_ins_age_TisFrac_int_sex 0.9989
#Glx
#basic age model
lag_glx_age<- lmer(Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id), data=lag_dat, REML=FALSE)
## boundary (singular) fit: see ?isSingular
summary(lag_glx_age)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1382.3 1397.4 -687.2 1374.3 314
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7144 -0.6884 0.0219 0.6876 3.5966
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.00 0.0
## Residual 4.41 2.1
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 23.21510 0.38755 318.00000 59.902 < 2e-16 ***
## mri_age_y -0.25957 0.06216 318.00000 -4.176 3.84e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## mri_age_y -0.953
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
#add tissue fraction
lag_glx_age_TisFrac<- lmer(Glu_Gln_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
## boundary (singular) fit: see ?isSingular
summary(lag_glx_age_TisFrac)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1233.6 1252.4 -611.8 1223.6 313
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.5280 -0.6316 -0.0148 0.6260 4.7387
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.000 0.000
## Residual 2.745 1.657
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 13.15202 0.78658 318.00000 16.72 <2e-16 ***
## mri_age_y 0.01589 0.05291 318.00000 0.30 0.764
## TissueFraction_GMWM 13.13565 0.94599 318.00000 13.89 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.689
## TssFrc_GMWM -0.921 0.375
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
#compare models
anova(lag_glx_age, lag_glx_age_TisFrac) #sig
## Data: lag_dat
## Models:
## lag_glx_age: Glu_Gln_conc_molal ~ mri_age_y + (1 | subj_id)
## lag_glx_age_TisFrac: Glu_Gln_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## lag_glx_age 4 1382.3 1397.4 -687.16 1374.3
## lag_glx_age_TisFrac 5 1233.6 1252.4 -611.81 1223.6 150.71 1 < 2.2e-16
##
## lag_glx_age
## lag_glx_age_TisFrac ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#add interaction
lag_glx_age_TisFrac_int<- lmer(Glu_Gln_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
## boundary (singular) fit: see ?isSingular
summary(lag_glx_age_TisFrac_int)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1233.1 1255.6 -610.5 1221.1 312
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7351 -0.6074 0.0091 0.5901 4.7202
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.000 0.00
## Residual 2.724 1.65
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 15.6977 1.7721 318.0000 8.858 < 2e-16 ***
## mri_age_y -0.3685 0.2457 318.0000 -1.500 0.13472
## TissueFraction_GMWM 8.9793 2.7610 318.0000 3.252 0.00127 **
## mri_age_y:TissueFraction_GMWM 0.6435 0.4018 318.0000 1.602 0.11026
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y TF_GMW
## mri_age_y -0.941
## TssFrc_GMWM -0.982 0.946
## m__:TF_GMWM 0.897 -0.977 -0.940
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
#compare models
anova(lag_glx_age_TisFrac, lag_glx_age_TisFrac_int) #not sig
## Data: lag_dat
## Models:
## lag_glx_age_TisFrac: Glu_Gln_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## lag_glx_age_TisFrac_int: Glu_Gln_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df
## lag_glx_age_TisFrac 5 1233.6 1252.4 -611.81 1223.6
## lag_glx_age_TisFrac_int 6 1233.1 1255.6 -610.53 1221.1 2.5545 1
## Pr(>Chisq)
## lag_glx_age_TisFrac
## lag_glx_age_TisFrac_int 0.11
#add sex
lag_glx_age_TisFrac_sex<- lmer(Glu_Gln_conc_molal ~ mri_age_y + TissueFraction_GMWM + female + (1 | subj_id), data=lag_dat, REML=FALSE)
## boundary (singular) fit: see ?isSingular
summary(lag_glx_age_TisFrac_sex)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y + TissueFraction_GMWM + female +
## (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1234.4 1257.0 -611.2 1222.4 312
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.4682 -0.6349 0.0098 0.6331 4.8061
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.000 0.000
## Residual 2.735 1.654
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 13.10115 0.78641 318.00000 16.659 <2e-16 ***
## mri_age_y 0.01315 0.05286 318.00000 0.249 0.804
## TissueFraction_GMWM 13.08982 0.94508 318.00000 13.851 <2e-16 ***
## female 0.20613 0.18612 318.00000 1.107 0.269
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y TF_GMW
## mri_age_y -0.684
## TssFrc_GMWM -0.916 0.376
## female -0.058 -0.047 -0.044
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
#compare models
anova(lag_glx_age_TisFrac, lag_glx_age_TisFrac_sex) #not sig
## Data: lag_dat
## Models:
## lag_glx_age_TisFrac: Glu_Gln_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## lag_glx_age_TisFrac_sex: Glu_Gln_conc_molal ~ mri_age_y + TissueFraction_GMWM + female + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df
## lag_glx_age_TisFrac 5 1233.6 1252.4 -611.81 1223.6
## lag_glx_age_TisFrac_sex 6 1234.4 1257.0 -611.19 1222.4 1.2241 1
## Pr(>Chisq)
## lag_glx_age_TisFrac
## lag_glx_age_TisFrac_sex 0.2686
#check models for multicollinearity
library(performance)
check_collinearity(lag_naa_age_TisFrac) #Low
## # Check for Multicollinearity
##
## Low Correlation
##
## Term VIF Increased SE Tolerance
## mri_age_y 1.18 1.09 0.84
## TissueFraction_GMWM 1.18 1.09 0.84
check_collinearity(lag_cre_age_TisFrac) #Low
## # Check for Multicollinearity
##
## Low Correlation
##
## Term VIF Increased SE Tolerance
## mri_age_y 1.18 1.09 0.84
## TissueFraction_GMWM 1.18 1.09 0.84
check_collinearity(lag_cho_age_TisFrac_int) #interaction term causes inflated VIFs - check model without interaction
## Warning: Model has interaction terms. VIFs might be inflated. You may check
## multicollinearity among predictors of a model without interaction terms.
## # Check for Multicollinearity
##
## High Correlation
##
## Term VIF Increased SE Tolerance
## mri_age_y 24.96 5.00 0.04
## TissueFraction_GMWM 10.05 3.17 0.10
## mri_age_y:TissueFraction_GMWM 22.01 4.69 0.05
check_collinearity(lag_cho_age_TisFrac) #Low
## # Check for Multicollinearity
##
## Low Correlation
##
## Term VIF Increased SE Tolerance
## mri_age_y 1.19 1.09 0.84
## TissueFraction_GMWM 1.19 1.09 0.84
check_collinearity(lag_ins_age_TisFrac) #Low
## # Check for Multicollinearity
##
## Low Correlation
##
## Term VIF Increased SE Tolerance
## mri_age_y 1.18 1.09 0.85
## TissueFraction_GMWM 1.18 1.09 0.85
check_collinearity(lag_glx_age_TisFrac) #Low
## # Check for Multicollinearity
##
## Low Correlation
##
## Term VIF Increased SE Tolerance
## mri_age_y 1.16 1.08 0.86
## TissueFraction_GMWM 1.16 1.08 0.86
##Unpack interactions Use sim_slopes function from interactions package to conduct simple slopes analysis on continuous x continuous interactions
library(interactions)
#LAG Cho: age x tissue fraction interaction
lag_cho_age_TisFrac_int<- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
#run simple slopes analysis with Johnson-Neyman plot
sim_slopes(lag_cho_age_TisFrac_int, pred = mri_age_y, modx = TissueFraction_GMWM, jnplot = TRUE)
## JOHNSON-NEYMAN INTERVAL
##
## When TissueFraction_GMWM is OUTSIDE the interval [-22.74, 0.44], the slope
## of mri_age_y is p < .05.
##
## Note: The range of observed values of TissueFraction_GMWM is [0.32, 0.85]
## SIMPLE SLOPES ANALYSIS
##
## Slope of mri_age_y when TissueFraction_GMWM = 0.5352733 (- 1 SD):
##
## Est. S.E. t val. p
## ------- ------ -------- ------
## -0.03 0.01 -3.93 0.00
##
## Slope of mri_age_y when TissueFraction_GMWM = 0.6413041 (Mean):
##
## Est. S.E. t val. p
## ------- ------ -------- ------
## -0.05 0.01 -5.63 0.00
##
## Slope of mri_age_y when TissueFraction_GMWM = 0.7473349 (+ 1 SD):
##
## Est. S.E. t val. p
## ------- ------ -------- ------
## -0.06 0.01 -5.01 0.00
#save Johnson-Neyman plot
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/lag_cho_age_tf_int_JNplot.png")
## Saving 7 x 5 in image
#create interaction plot (make it pretty later)
#basic plot
Cho_age_tf_int_plot <- interact_plot(lag_cho_age_TisFrac_int, pred = mri_age_y, modx = TissueFraction_GMWM)
Cho_age_tf_int_plot
#linearity check
Cho_age_tf_int_plot_lin <- interact_plot(lag_cho_age_TisFrac_int, pred = mri_age_y, modx = TissueFraction_GMWM, modx.values="terciles", plot.points=TRUE, linearity.check=TRUE)
## Medians of each tercile of TissueFraction_GMWM are 0.539, 0.655, 0.746
Cho_age_tf_int_plot_lin
## `geom_smooth()` using formula 'y ~ x'
#seems to be some non-linear effects, try adding quadratic term
#LAG Ins: age x tissue fraction interaction
lag_ins_age_TisFrac_int<- lmer(Ins_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
#run simple slopes analysis with Johnson-Neyman plot
sim_slopes(lag_ins_age_TisFrac_int, pred = mri_age_y, modx = TissueFraction_GMWM, jnplot = TRUE)
## JOHNSON-NEYMAN INTERVAL
##
## When TissueFraction_GMWM is OUTSIDE the interval [0.58, 1.14], the slope of
## mri_age_y is p < .05.
##
## Note: The range of observed values of TissueFraction_GMWM is [0.32, 0.85]
## SIMPLE SLOPES ANALYSIS
##
## Slope of mri_age_y when TissueFraction_GMWM = 0.5350189 (- 1 SD):
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.11 0.04 2.61 0.01
##
## Slope of mri_age_y when TissueFraction_GMWM = 0.6412007 (Mean):
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.03 0.04 0.88 0.38
##
## Slope of mri_age_y when TissueFraction_GMWM = 0.7473825 (+ 1 SD):
##
## Est. S.E. t val. p
## ------- ------ -------- ------
## -0.04 0.06 -0.69 0.49
#save Johnson-Neyman plot
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/lag_ins_age_tf_int_JNplot.png")
## Saving 7 x 5 in image
#create interaction plot (make it pretty later)
#basic plot
Ins_age_tf_int_plot <- interact_plot(lag_ins_age_TisFrac_int, pred = mri_age_y, modx = TissueFraction_GMWM)
Ins_age_tf_int_plot
#linearity check
Ins_age_tf_int_plot_lin <- interact_plot(lag_ins_age_TisFrac_int, pred = mri_age_y, modx = TissueFraction_GMWM, modx.values="terciles", plot.points=TRUE, linearity.check=TRUE)
## Medians of each tercile of TissueFraction_GMWM are 0.539, 0.654, 0.746
Ins_age_tf_int_plot_lin
## `geom_smooth()` using formula 'y ~ x'
#seems to be some non-linear effects - try adding quadratic term
##Test quadratic effects of age with tissue fraction covariate in LAG models Interaction plots showed some nonlinear effects, so testing quadratic effects of age
#create quadratic age variable
lag_dat$mri_age_y2<- (lag_dat$mri_age_y)^2
#NAA
#age + tissue fraction model
lag_naa_age_TisFrac <- lmer(NAA_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_naa_age_TisFrac)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: NAA_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 855.9 874.7 -423.0 845.9 312
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.9760 -0.5775 -0.0185 0.5568 3.9394
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1614 0.4017
## Residual 0.7209 0.8491
## Number of obs: 317, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 11.27969 0.44221 316.99130 25.508 < 2e-16 ***
## mri_age_y 0.17139 0.02968 316.93976 5.775 1.84e-08 ***
## TissueFraction_GMWM 3.27768 0.52579 314.11297 6.234 1.46e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.700
## TssFrc_GMWM -0.918 0.395
#add quadratic age term with all interactions
lag_naa_age_TisFrac_quad <- lmer(NAA_conc_molal ~ mri_age_y * mri_age_y2 * TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning: Some predictor variables are on very different scales: consider
## rescaling
summary(lag_naa_age_TisFrac_quad) #no sig. effects
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: NAA_conc_molal ~ mri_age_y * mri_age_y2 * TissueFraction_GMWM +
## (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 860.2 897.7 -420.1 840.2 307
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.1198 -0.5220 -0.0230 0.5474 3.9037
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1612 0.4015
## Residual 0.7063 0.8404
## Number of obs: 317, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) -2.70817 10.72178 310.17078 -0.253
## mri_age_y 6.19502 5.02438 310.19644 1.233
## mri_age_y2 -0.83989 0.74366 309.90807 -1.129
## TissueFraction_GMWM 23.29080 16.85908 311.68207 1.381
## mri_age_y:mri_age_y2 0.03890 0.03529 309.31084 1.102
## mri_age_y:TissueFraction_GMWM -8.71960 8.04364 311.65504 -1.084
## mri_age_y2:TissueFraction_GMWM 1.24512 1.21847 311.13962 1.022
## mri_age_y:mri_age_y2:TissueFraction_GMWM -0.05977 0.05941 310.20651 -1.006
## Pr(>|t|)
## (Intercept) 0.801
## mri_age_y 0.219
## mri_age_y2 0.260
## TissueFraction_GMWM 0.168
## mri_age_y:mri_age_y2 0.271
## mri_age_y:TissueFraction_GMWM 0.279
## mri_age_y2:TissueFraction_GMWM 0.308
## mri_age_y:mri_age_y2:TissueFraction_GMWM 0.315
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y mr_g_2 TF_GMW mr__:__2 m__:TF m__2:T
## mri_age_y -0.992
## mri_age_y2 0.970 -0.992
## TssFrc_GMWM -0.986 0.985 -0.972
## mr_g_y:m__2 -0.936 0.971 -0.993 0.948
## m__:TF_GMWM 0.969 -0.985 0.986 -0.992 -0.975
## m__2:TF_GMW -0.936 0.965 -0.983 0.968 0.987 -0.992
## m__:__2:TF_ 0.890 -0.931 0.962 -0.931 -0.981 0.968 -0.992
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
anova(lag_naa_age_TisFrac, lag_naa_age_TisFrac_quad) #not sig.
## Data: lag_dat
## Models:
## lag_naa_age_TisFrac: NAA_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## lag_naa_age_TisFrac_quad: NAA_conc_molal ~ mri_age_y * mri_age_y2 * TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df
## lag_naa_age_TisFrac 5 855.92 874.71 -422.96 845.92
## lag_naa_age_TisFrac_quad 10 860.16 897.74 -420.08 840.16 5.7617 5
## Pr(>Chisq)
## lag_naa_age_TisFrac
## lag_naa_age_TisFrac_quad 0.3301
#Cre
#age + tissue fraction model
lag_cre_age_TisFrac<- lmer(Cre_PCr_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cre_age_TisFrac)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cre_PCr_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 758.9 777.7 -374.4 748.9 314
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7436 -0.5047 0.0268 0.4405 4.8766
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.08544 0.2923
## Residual 0.54309 0.7369
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 7.05033 0.37589 318.62021 18.756 <2e-16 ***
## mri_age_y 0.05654 0.02505 318.77753 2.257 0.0247 *
## TissueFraction_GMWM 4.46604 0.44851 318.00128 9.957 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.699
## TssFrc_GMWM -0.920 0.395
#add quadratic age term with all interactions
lag_cre_age_TisFrac_quad<- lmer(Cre_PCr_conc_molal ~ mri_age_y * mri_age_y2 * TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning: Some predictor variables are on very different scales: consider
## rescaling
summary(lag_cre_age_TisFrac_quad)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cre_PCr_conc_molal ~ mri_age_y * mri_age_y2 * TissueFraction_GMWM +
## (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 762.1 799.7 -371.0 742.1 309
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.6019 -0.5622 0.0261 0.4910 5.0205
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.08585 0.2930
## Residual 0.53016 0.7281
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 18.54292 9.07954 315.26475 2.042
## mri_age_y -6.12338 4.25338 315.35287 -1.440
## mri_age_y2 1.02870 0.62902 315.14894 1.635
## TissueFraction_GMWM -16.94852 14.20044 316.56022 -1.194
## mri_age_y:mri_age_y2 -0.05356 0.02981 314.65873 -1.797
## mri_age_y:TissueFraction_GMWM 11.64181 6.76953 316.56519 1.720
## mri_age_y2:TissueFraction_GMWM -1.96597 1.02385 316.15645 -1.920
## mri_age_y:mri_age_y2:TissueFraction_GMWM 0.10401 0.04981 315.37228 2.088
## Pr(>|t|)
## (Intercept) 0.0420 *
## mri_age_y 0.1510
## mri_age_y2 0.1030
## TissueFraction_GMWM 0.2336
## mri_age_y:mri_age_y2 0.0734 .
## mri_age_y:TissueFraction_GMWM 0.0865 .
## mri_age_y2:TissueFraction_GMWM 0.0557 .
## mri_age_y:mri_age_y2:TissueFraction_GMWM 0.0376 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y mr_g_2 TF_GMW mr__:__2 m__:TF m__2:T
## mri_age_y -0.992
## mri_age_y2 0.969 -0.992
## TssFrc_GMWM -0.987 0.986 -0.972
## mr_g_y:m__2 -0.936 0.971 -0.993 0.947
## m__:TF_GMWM 0.970 -0.985 0.986 -0.991 -0.975
## m__2:TF_GMW -0.936 0.966 -0.983 0.967 0.987 -0.992
## m__:__2:TF_ 0.890 -0.932 0.963 -0.931 -0.981 0.968 -0.992
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
#compare models
anova(lag_cre_age_TisFrac, lag_cre_age_TisFrac_quad) #not sig.
## Data: lag_dat
## Models:
## lag_cre_age_TisFrac: Cre_PCr_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## lag_cre_age_TisFrac_quad: Cre_PCr_conc_molal ~ mri_age_y * mri_age_y2 * TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df
## lag_cre_age_TisFrac 5 758.87 777.70 -374.44 748.87
## lag_cre_age_TisFrac_quad 10 762.07 799.72 -371.03 742.07 6.806 5
## Pr(>Chisq)
## lag_cre_age_TisFrac
## lag_cre_age_TisFrac_quad 0.2355
#Cho
#age x tissue fraction interaction model
lag_cho_age_TisFrac_int<- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_cho_age_TisFrac_int) #interaction is sig. (p=.046)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Cho_GPC_PCh_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 |
## subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 19.4 42.0 -3.7 7.4 313
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.5433 -0.6283 -0.0528 0.4926 4.5229
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.01209 0.1100
## Residual 0.05082 0.2254
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.50966 0.26145 309.45711 9.599 <2e-16
## mri_age_y 0.02861 0.03588 301.15695 0.798 0.4257
## TissueFraction_GMWM -0.05546 0.40621 306.63258 -0.137 0.8915
## mri_age_y:TissueFraction_GMWM -0.11698 0.05855 299.02369 -1.998 0.0466
##
## (Intercept) ***
## mri_age_y
## TissueFraction_GMWM
## mri_age_y:TissueFraction_GMWM *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y TF_GMW
## mri_age_y -0.940
## TssFrc_GMWM -0.981 0.946
## m__:TF_GMWM 0.893 -0.976 -0.939
#add quadratic age term with all interactions
lag_cho_age_TisFrac_int_quad <- lmer(Cho_GPC_PCh_conc_molal ~ mri_age_y * mri_age_y2 * TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning: Some predictor variables are on very different scales: consider
## rescaling
summary(lag_cho_age_TisFrac_int_quad) #no sig. effects
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula:
## Cho_GPC_PCh_conc_molal ~ mri_age_y * mri_age_y2 * TissueFraction_GMWM +
## (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 23.9 61.5 -1.9 3.9 309
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.4614 -0.6109 -0.0419 0.4819 4.5938
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.01269 0.1126
## Residual 0.04985 0.2233
## Number of obs: 319, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 3.060978 2.837224 308.247149
## mri_age_y -0.071877 1.329127 308.127460
## mri_age_y2 -0.007871 0.196525 307.472803
## TissueFraction_GMWM -0.698059 4.440983 310.007268
## mri_age_y:mri_age_y2 0.001155 0.009311 306.334446
## mri_age_y:TissueFraction_GMWM -0.004647 2.116989 309.804523
## mri_age_y2:TissueFraction_GMWM 0.008588 0.320067 308.774597
## mri_age_y:mri_age_y2:TissueFraction_GMWM -0.001097 0.015563 307.071649
## t value Pr(>|t|)
## (Intercept) 1.079 0.281
## mri_age_y -0.054 0.957
## mri_age_y2 -0.040 0.968
## TissueFraction_GMWM -0.157 0.875
## mri_age_y:mri_age_y2 0.124 0.901
## mri_age_y:TissueFraction_GMWM -0.002 0.998
## mri_age_y2:TissueFraction_GMWM 0.027 0.979
## mri_age_y:mri_age_y2:TissueFraction_GMWM -0.070 0.944
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y mr_g_2 TF_GMW mr__:__2 m__:TF m__2:T
## mri_age_y -0.992
## mri_age_y2 0.969 -0.992
## TssFrc_GMWM -0.986 0.986 -0.972
## mr_g_y:m__2 -0.936 0.971 -0.993 0.947
## m__:TF_GMWM 0.969 -0.985 0.986 -0.991 -0.975
## m__2:TF_GMW -0.936 0.966 -0.983 0.967 0.987 -0.992
## m__:__2:TF_ 0.891 -0.932 0.963 -0.931 -0.981 0.968 -0.992
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
#compare model fit
anova(lag_cho_age_TisFrac_int, lag_cho_age_TisFrac_int_quad) #not sig., stick with age x tissue fraction model
## Data: lag_dat
## Models:
## lag_cho_age_TisFrac_int: Cho_GPC_PCh_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id)
## lag_cho_age_TisFrac_int_quad: Cho_GPC_PCh_conc_molal ~ mri_age_y * mri_age_y2 * TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df
## lag_cho_age_TisFrac_int 6 19.360 41.952 -3.6803 7.3605
## lag_cho_age_TisFrac_int_quad 10 23.887 61.539 -1.9435 3.8870 3.4735 4
## Pr(>Chisq)
## lag_cho_age_TisFrac_int
## lag_cho_age_TisFrac_int_quad 0.4819
#Ins
#age x tissue fraction interaction model
lag_ins_age_TisFrac_int<- lmer(Ins_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
summary(lag_ins_age_TisFrac_int) #tissue fraction, age & interaction all sig.
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 999.1 1021.7 -493.6 987.1 312
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.3920 -0.5998 0.0019 0.5704 4.7105
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1743 0.4175
## Residual 1.1625 1.0782
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.9626 1.2270 314.8718 1.599 0.110715
## mri_age_y 0.4673 0.1688 309.0840 2.768 0.005987 **
## TissueFraction_GMWM 6.5078 1.9084 313.2225 3.410 0.000735 ***
## mri_age_y:TissueFraction_GMWM -0.6761 0.2758 307.1983 -2.451 0.014794 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y TF_GMW
## mri_age_y -0.941
## TssFrc_GMWM -0.981 0.946
## m__:TF_GMWM 0.894 -0.976 -0.939
#add quadratic age term with all interactions
lag_ins_age_TisFrac_int_quad<- lmer(Ins_conc_molal ~ mri_age_y * mri_age_y2 * TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## Warning: Some predictor variables are on very different scales: consider
## rescaling
summary(lag_ins_age_TisFrac_int_quad) #no sig. effects
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Ins_conc_molal ~ mri_age_y * mri_age_y2 * TissueFraction_GMWM +
## (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1004.9 1042.6 -492.5 984.9 308
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.4406 -0.6141 0.0123 0.5926 4.7410
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.1751 0.4185
## Residual 1.1532 1.0739
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 11.20505 13.36364 314.14391 0.838
## mri_age_y -3.87725 6.26077 314.26381 -0.619
## mri_age_y2 0.62035 0.92600 314.06407 0.670
## TissueFraction_GMWM -4.80642 20.90353 315.65728 -0.230
## mri_age_y:mri_age_y2 -0.02713 0.04389 313.55457 -0.618
## mri_age_y:TissueFraction_GMWM 4.42865 9.96659 315.68365 0.444
## mri_age_y2:TissueFraction_GMWM -0.68411 1.50774 315.27106 -0.454
## mri_age_y:mri_age_y2:TissueFraction_GMWM 0.02711 0.07337 314.46090 0.370
## Pr(>|t|)
## (Intercept) 0.402
## mri_age_y 0.536
## mri_age_y2 0.503
## TissueFraction_GMWM 0.818
## mri_age_y:mri_age_y2 0.537
## mri_age_y:TissueFraction_GMWM 0.657
## mri_age_y2:TissueFraction_GMWM 0.650
## mri_age_y:mri_age_y2:TissueFraction_GMWM 0.712
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y mr_g_2 TF_GMW mr__:__2 m__:TF m__2:T
## mri_age_y -0.992
## mri_age_y2 0.969 -0.992
## TssFrc_GMWM -0.987 0.986 -0.972
## mr_g_y:m__2 -0.936 0.971 -0.993 0.947
## m__:TF_GMWM 0.970 -0.985 0.986 -0.991 -0.975
## m__2:TF_GMW -0.936 0.966 -0.983 0.967 0.987 -0.992
## m__:__2:TF_ 0.890 -0.932 0.963 -0.931 -0.981 0.968 -0.992
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
anova(lag_ins_age_TisFrac_int, lag_ins_age_TisFrac_int_quad) #not sig.
## Data: lag_dat
## Models:
## lag_ins_age_TisFrac_int: Ins_conc_molal ~ mri_age_y * TissueFraction_GMWM + (1 | subj_id)
## lag_ins_age_TisFrac_int_quad: Ins_conc_molal ~ mri_age_y * mri_age_y2 * TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df
## lag_ins_age_TisFrac_int 6 999.13 1021.7 -493.56 987.13
## lag_ins_age_TisFrac_int_quad 10 1004.95 1042.6 -492.47 984.95 2.1778 4
## Pr(>Chisq)
## lag_ins_age_TisFrac_int
## lag_ins_age_TisFrac_int_quad 0.7031
#Glx
#age + tissue fraction model
lag_glx_age_TisFrac<- lmer(Glu_Gln_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
## boundary (singular) fit: see ?isSingular
summary(lag_glx_age_TisFrac)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1233.6 1252.4 -611.8 1223.6 313
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.5280 -0.6316 -0.0148 0.6260 4.7387
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.000 0.000
## Residual 2.745 1.657
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 13.15202 0.78658 318.00000 16.72 <2e-16 ***
## mri_age_y 0.01589 0.05291 318.00000 0.30 0.764
## TissueFraction_GMWM 13.13565 0.94599 318.00000 13.89 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y
## mri_age_y -0.689
## TssFrc_GMWM -0.921 0.375
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
#add quadratic age term with all interactions
lag_glx_age_TisFrac_quad<- lmer(Glu_Gln_conc_molal ~ mri_age_y * mri_age_y2 * TissueFraction_GMWM + (1 | subj_id), data=lag_dat, REML=FALSE)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
## boundary (singular) fit: see ?isSingular
## Warning: Some predictor variables are on very different scales: consider
## rescaling
summary(lag_glx_age_TisFrac_quad) #no sig. effects
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
## method [lmerModLmerTest]
## Formula: Glu_Gln_conc_molal ~ mri_age_y * mri_age_y2 * TissueFraction_GMWM +
## (1 | subj_id)
## Data: lag_dat
##
## AIC BIC logLik deviance df.resid
## 1229.0 1266.7 -604.5 1209.0 308
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.3652 -0.6327 0.0433 0.5740 4.6439
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj_id (Intercept) 0.000 0.000
## Residual 2.622 1.619
## Number of obs: 318, groups: subj_id, 95
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 25.16742 19.13166 318.00000 1.315
## mri_age_y -6.61392 8.96441 318.00000 -0.738
## mri_age_y2 1.16626 1.32726 318.00000 0.879
## TissueFraction_GMWM -9.64196 29.87655 318.00000 -0.323
## mri_age_y:mri_age_y2 -0.06260 0.06304 318.00000 -0.993
## mri_age_y:TissueFraction_GMWM 11.59288 14.26161 318.00000 0.813
## mri_age_y2:TissueFraction_GMWM -1.88694 2.16339 318.00000 -0.872
## mri_age_y:mri_age_y2:TissueFraction_GMWM 0.09490 0.10572 318.00000 0.898
## Pr(>|t|)
## (Intercept) 0.189
## mri_age_y 0.461
## mri_age_y2 0.380
## TissueFraction_GMWM 0.747
## mri_age_y:mri_age_y2 0.321
## mri_age_y:TissueFraction_GMWM 0.417
## mri_age_y2:TissueFraction_GMWM 0.384
## mri_age_y:mri_age_y2:TissueFraction_GMWM 0.370
##
## Correlation of Fixed Effects:
## (Intr) mr_g_y mr_g_2 TF_GMW mr__:__2 m__:TF m__2:T
## mri_age_y -0.992
## mri_age_y2 0.969 -0.992
## TssFrc_GMWM -0.987 0.986 -0.972
## mr_g_y:m__2 -0.935 0.970 -0.993 0.947
## m__:TF_GMWM 0.969 -0.985 0.986 -0.991 -0.975
## m__2:TF_GMW -0.935 0.965 -0.983 0.966 0.987 -0.991
## m__:__2:TF_ 0.887 -0.929 0.962 -0.929 -0.981 0.967 -0.992
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
#warning: boundary fit is singular
#compare models
anova(lag_glx_age_TisFrac, lag_glx_age_TisFrac_quad) #significant
## Data: lag_dat
## Models:
## lag_glx_age_TisFrac: Glu_Gln_conc_molal ~ mri_age_y + TissueFraction_GMWM + (1 | subj_id)
## lag_glx_age_TisFrac_quad: Glu_Gln_conc_molal ~ mri_age_y * mri_age_y2 * TissueFraction_GMWM + (1 | subj_id)
## npar AIC BIC logLik deviance Chisq Df
## lag_glx_age_TisFrac 5 1233.6 1252.4 -611.81 1223.6
## lag_glx_age_TisFrac_quad 10 1229.0 1266.7 -604.52 1209.0 14.576 5
## Pr(>Chisq)
## lag_glx_age_TisFrac
## lag_glx_age_TisFrac_quad 0.01234 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##Print model summaries Print formatted model summaries and tables using report and sjplot package
library(sjPlot) #for pretty summary tables
## Install package "strengejacke" from GitHub (`devtools::install_github("strengejacke/strengejacke")`) to load all sj-packages at once!
library(report) #for text summaries
#create html summary table for sig. models ACG
acg_summary_table_sig<-tab_model(acg_naa_age, acg_cho_age, acg_ins_age, dv.labels = c("tNAA (molal)", "tCho (molal)", "Ins (molal)"), pred.labels = c("(Intercept)", "Age (years)"))
acg_summary_table_sig #opens in Rstudio viewer, can open from there to web browser and save as PDF or whatever
| tNAA (molal) | tCho (molal) | Ins (molal) | |||||||
|---|---|---|---|---|---|---|---|---|---|
| Predictors | Estimates | CI | p | Estimates | CI | p | Estimates | CI | p |
| (Intercept) | 14.06 | 13.19 – 14.92 | <0.001 | 2.77 | 2.53 – 3.00 | <0.001 | 8.63 | 7.56 – 9.71 | <0.001 |
| Age (years) | 0.22 | 0.02 – 0.42 | 0.035 | -0.07 | -0.12 – -0.01 | 0.016 | -0.24 | -0.49 – 0.02 | 0.065 |
| Random Effects | |||||||||
| σ2 | 0.63 | 0.08 | 1.34 | ||||||
| τ00 | 0.89 subj_id | 0.03 subj_id | 0.92 subj_id | ||||||
| ICC | 0.58 | 0.27 | 0.41 | ||||||
| N | 101 subj_id | 100 subj_id | 100 subj_id | ||||||
| Observations | 112 | 111 | 111 | ||||||
| Marginal R2 / Conditional R2 | 0.037 / 0.599 | 0.051 / 0.311 | 0.030 / 0.425 | ||||||
#create html summary table for all models ACG
acg_summary_table_all<-tab_model(acg_naa_age, acg_cre_age, acg_cho_age, acg_ins_age, acg_glx_age, dv.labels = c("tNAA (molal)", "tCre (molal)", "tCho (molal)", "Ins (molal)", "Glx (molal)"), pred.labels = c("(Intercept)", "Age (years)"))
acg_summary_table_all #opens in Rstudio viewer, can open from there to web browser and save as PDF or whatever
| tNAA (molal) | tCre (molal) | tCho (molal) | Ins (molal) | Glx (molal) | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Predictors | Estimates | CI | p | Estimates | CI | p | Estimates | CI | p | Estimates | CI | p | Estimates | CI | p |
| (Intercept) | 14.06 | 13.19 – 14.92 | <0.001 | 11.86 | 11.14 – 12.59 | <0.001 | 2.77 | 2.53 – 3.00 | <0.001 | 8.63 | 7.56 – 9.71 | <0.001 | 25.89 | 24.08 – 27.70 | <0.001 |
| Age (years) | 0.22 | 0.02 – 0.42 | 0.035 | 0.06 | -0.11 – 0.22 | 0.513 | -0.07 | -0.12 – -0.01 | 0.016 | -0.24 | -0.49 – 0.02 | 0.065 | 0.24 | -0.18 – 0.67 | 0.257 |
| Random Effects | |||||||||||||||
| σ2 | 0.63 | 0.51 | 0.08 | 1.34 | 2.34 | ||||||||||
| τ00 | 0.89 subj_id | 0.53 subj_id | 0.03 subj_id | 0.92 subj_id | 4.55 subj_id | ||||||||||
| ICC | 0.58 | 0.51 | 0.27 | 0.41 | 0.66 | ||||||||||
| N | 101 subj_id | 101 subj_id | 100 subj_id | 100 subj_id | 101 subj_id | ||||||||||
| Observations | 112 | 112 | 111 | 111 | 112 | ||||||||||
| Marginal R2 / Conditional R2 | 0.037 / 0.599 | 0.004 / 0.510 | 0.051 / 0.311 | 0.030 / 0.425 | 0.011 / 0.664 | ||||||||||
#output text summaries for sig. ACG models
report(acg_naa_age)
## 'interpret_d()' is now deprecated. Please use 'interpret_cohens_d()'.
## 'interpret_d()' is now deprecated. Please use 'interpret_cohens_d()'.
## We fitted a linear mixed model (estimated using ML and nloptwrap optimizer) to predict NAA_conc_molal with mri_age_y (formula: NAA_conc_molal ~ mri_age_y). The model included subj_id as random effect (formula: ~1 | subj_id). The model's total explanatory power is substantial (conditional R2 = 0.60) and the part related to the fixed effects alone (marginal R2) is of 0.04. The model's intercept, corresponding to mri_age_y = 0, is at 14.06 (95% CI [13.19, 14.92], t(108) = 32.23, p < .001). Within this model:
##
## - The effect of mri age y is statistically significant and positive (beta = 0.22, 95% CI [0.02, 0.42], t(108) = 2.13, p = 0.035; Std. beta = 0.19, 95% CI [0.01, 0.38])
##
## Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using
report(acg_cho_age)
## 'interpret_d()' is now deprecated. Please use 'interpret_cohens_d()'.
## 'interpret_d()' is now deprecated. Please use 'interpret_cohens_d()'.
## We fitted a linear mixed model (estimated using ML and nloptwrap optimizer) to predict Cho_GPC_PCh_conc_molal with mri_age_y (formula: Cho_GPC_PCh_conc_molal ~ mri_age_y). The model included subj_id as random effect (formula: ~1 | subj_id). The model's total explanatory power is substantial (conditional R2 = 0.31) and the part related to the fixed effects alone (marginal R2) is of 0.05. The model's intercept, corresponding to mri_age_y = 0, is at 2.77 (95% CI [2.53, 3.00], t(107) = 23.54, p < .001). Within this model:
##
## - The effect of mri age y is statistically significant and negative (beta = -0.07, 95% CI [-0.12, -0.01], t(107) = -2.45, p = 0.016; Std. beta = -0.22, 95% CI [-0.41, -0.04])
##
## Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using
#create html summary table for sig. models LAG
lag_summary_table_sig<-tab_model(lag_naa_age_TisFrac, lag_cre_age_TisFrac, lag_cho_age_TisFrac_int, lag_ins_age_TisFrac_int, dv.labels = c("tNAA (molal)", "tCre (molal)", "tCho (molal)", "Ins (molal)"), pred.labels = c("(Intercept)", "Age (years)", "Tissue Fraction GM/(WM+GM)", "Age:Tissue Fraction"))
lag_summary_table_sig
| tNAA (molal) | tCre (molal) | tCho (molal) | Ins (molal) | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Predictors | Estimates | CI | p | Estimates | CI | p | Estimates | CI | p | Estimates | CI | p |
| (Intercept) | 11.28 | 10.41 – 12.15 | <0.001 | 7.05 | 6.31 – 7.79 | <0.001 | 2.51 | 2.00 – 3.02 | <0.001 | 1.96 | -0.45 – 4.38 | 0.111 |
| Age (years) | 0.17 | 0.11 – 0.23 | <0.001 | 0.06 | 0.01 – 0.11 | 0.025 | 0.03 | -0.04 – 0.10 | 0.426 | 0.47 | 0.14 – 0.80 | 0.006 |
| Tissue Fraction GM/(WM+GM) | 3.28 | 2.24 – 4.31 | <0.001 | 4.47 | 3.58 – 5.35 | <0.001 | -0.06 | -0.85 – 0.74 | 0.891 | 6.51 | 2.75 – 10.26 | 0.001 |
| Age:Tissue Fraction | -0.12 | -0.23 – -0.00 | 0.047 | -0.68 | -1.22 – -0.13 | 0.015 | ||||||
| Random Effects | ||||||||||||
| σ2 | 0.72 | 0.54 | 0.05 | 1.16 | ||||||||
| τ00 | 0.16 subj_id | 0.09 subj_id | 0.01 subj_id | 0.17 subj_id | ||||||||
| ICC | 0.18 | 0.14 | 0.19 | 0.13 | ||||||||
| N | 95 subj_id | 95 subj_id | 95 subj_id | 95 subj_id | ||||||||
| Observations | 317 | 319 | 319 | 318 | ||||||||
| Marginal R2 / Conditional R2 | 0.139 / 0.296 | 0.239 / 0.342 | 0.128 / 0.296 | 0.050 / 0.174 | ||||||||
#create html summary table for all models LAG
lag_summary_table_all<-tab_model(lag_naa_age_TisFrac, lag_cre_age_TisFrac, lag_cho_age_TisFrac_int, lag_ins_age_TisFrac_int, lag_glx_age_TisFrac_quad, dv.labels = c("tNAA (molal)", "tCre (molal)", "tCho (molal)", "Ins (molal)", "Glx (molal)"), pred.labels = c("(Intercept)", "Age (years)", "Tissue Fraction GM/(WM+GM)", "Age:Tissue Fraction", "Age^2", "Age:Age^2", "Age^2:Tissue Fraction", "Age:Age^2:Tissue Fraction"))
lag_summary_table_all
| tNAA (molal) | tCre (molal) | tCho (molal) | Ins (molal) | Glx (molal) | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Predictors | Estimates | CI | p | Estimates | CI | p | Estimates | CI | p | Estimates | CI | p | Estimates | CI | p |
| (Intercept) | 11.28 | 10.41 – 12.15 | <0.001 | 7.05 | 6.31 – 7.79 | <0.001 | 2.51 | 2.00 – 3.02 | <0.001 | 1.96 | -0.45 – 4.38 | 0.111 | 25.17 | -12.48 – 62.81 | 0.189 |
| Age (years) | 0.17 | 0.11 – 0.23 | <0.001 | 0.06 | 0.01 – 0.11 | 0.025 | 0.03 | -0.04 – 0.10 | 0.426 | 0.47 | 0.14 – 0.80 | 0.006 | -6.61 | -24.25 – 11.03 | 0.461 |
| Tissue Fraction GM/(WM+GM) | 3.28 | 2.24 – 4.31 | <0.001 | 4.47 | 3.58 – 5.35 | <0.001 | -0.06 | -0.85 – 0.74 | 0.891 | 6.51 | 2.75 – 10.26 | 0.001 | -9.64 | -68.43 – 49.15 | 0.747 |
| Age:Tissue Fraction | -0.12 | -0.23 – -0.00 | 0.047 | -0.68 | -1.22 – -0.13 | 0.015 | 11.59 | -16.47 – 39.66 | 0.417 | ||||||
| Age^2 | 1.17 | -1.45 – 3.78 | 0.380 | ||||||||||||
| Age:Age^2 | -0.06 | -0.19 – 0.06 | 0.321 | ||||||||||||
| Age^2:Tissue Fraction | -1.89 | -6.14 – 2.37 | 0.384 | ||||||||||||
| Age:Age^2:Tissue Fraction | 0.09 | -0.11 – 0.30 | 0.370 | ||||||||||||
| Random Effects | |||||||||||||||
| σ2 | 0.72 | 0.54 | 0.05 | 1.16 | 2.62 | ||||||||||
| τ00 | 0.16 subj_id | 0.09 subj_id | 0.01 subj_id | 0.17 subj_id | 0.00 subj_id | ||||||||||
| ICC | 0.18 | 0.14 | 0.19 | 0.13 | |||||||||||
| N | 95 subj_id | 95 subj_id | 95 subj_id | 95 subj_id | 95 subj_id | ||||||||||
| Observations | 317 | 319 | 319 | 318 | 318 | ||||||||||
| Marginal R2 / Conditional R2 | 0.139 / 0.296 | 0.239 / 0.342 | 0.128 / 0.296 | 0.050 / 0.174 | 0.437 / NA | ||||||||||
report(lag_naa_age_TisFrac)
## 'interpret_d()' is now deprecated. Please use 'interpret_cohens_d()'.
## 'interpret_d()' is now deprecated. Please use 'interpret_cohens_d()'.
## We fitted a linear mixed model (estimated using ML and nloptwrap optimizer) to predict NAA_conc_molal with mri_age_y and TissueFraction_GMWM (formula: NAA_conc_molal ~ mri_age_y + TissueFraction_GMWM). The model included subj_id as random effect (formula: ~1 | subj_id). The model's total explanatory power is substantial (conditional R2 = 0.30) and the part related to the fixed effects alone (marginal R2) is of 0.14. The model's intercept, corresponding to mri_age_y = 0 and TissueFraction_GMWM = 0, is at 11.28 (95% CI [10.41, 12.15], t(312) = 25.51, p < .001). Within this model:
##
## - The effect of mri age y is statistically significant and positive (beta = 0.17, 95% CI [0.11, 0.23], t(312) = 5.77, p < .001; Std. beta = 0.32, 95% CI [0.21, 0.43])
## - The effect of TissueFraction GMWM is statistically significant and positive (beta = 3.28, 95% CI [2.24, 4.31], t(312) = 6.23, p < .001; Std. beta = 0.34, 95% CI [0.23, 0.45])
##
## Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using
report(lag_cre_age_TisFrac)
## 'interpret_d()' is now deprecated. Please use 'interpret_cohens_d()'.
## 'interpret_d()' is now deprecated. Please use 'interpret_cohens_d()'.
## We fitted a linear mixed model (estimated using ML and nloptwrap optimizer) to predict Cre_PCr_conc_molal with mri_age_y and TissueFraction_GMWM (formula: Cre_PCr_conc_molal ~ mri_age_y + TissueFraction_GMWM). The model included subj_id as random effect (formula: ~1 | subj_id). The model's total explanatory power is substantial (conditional R2 = 0.34) and the part related to the fixed effects alone (marginal R2) is of 0.24. The model's intercept, corresponding to mri_age_y = 0 and TissueFraction_GMWM = 0, is at 7.05 (95% CI [6.31, 7.79], t(314) = 18.76, p < .001). Within this model:
##
## - The effect of mri age y is statistically significant and positive (beta = 0.06, 95% CI [7.25e-03, 0.11], t(314) = 2.26, p = 0.025; Std. beta = 0.12, 95% CI [0.02, 0.22])
## - The effect of TissueFraction GMWM is statistically significant and positive (beta = 4.47, 95% CI [3.58, 5.35], t(314) = 9.96, p < .001; Std. beta = 0.52, 95% CI [0.42, 0.63])
##
## Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using
report(lag_cho_age_TisFrac_int)
## 'interpret_d()' is now deprecated. Please use 'interpret_cohens_d()'.
## 'interpret_d()' is now deprecated. Please use 'interpret_cohens_d()'.
## We fitted a linear mixed model (estimated using ML and nloptwrap optimizer) to predict Cho_GPC_PCh_conc_molal with mri_age_y and TissueFraction_GMWM (formula: Cho_GPC_PCh_conc_molal ~ mri_age_y * TissueFraction_GMWM). The model included subj_id as random effect (formula: ~1 | subj_id). The model's total explanatory power is substantial (conditional R2 = 0.30) and the part related to the fixed effects alone (marginal R2) is of 0.13. The model's intercept, corresponding to mri_age_y = 0 and TissueFraction_GMWM = 0, is at 2.51 (95% CI [2.00, 3.02], t(313) = 9.60, p < .001). Within this model:
##
## - The effect of mri age y is statistically non-significant and positive (beta = 0.03, 95% CI [-0.04, 0.10], t(313) = 0.80, p = 0.426; Std. beta = -0.33, 95% CI [-0.44, -0.21])
## - The effect of TissueFraction GMWM is statistically non-significant and negative (beta = -0.06, 95% CI [-0.85, 0.74], t(313) = -0.14, p = 0.891; Std. beta = -0.30, 95% CI [-0.41, -0.18])
## - The interaction effect of TissueFraction GMWM on mri age y is statistically significant and negative (beta = -0.12, 95% CI [-0.23, -1.77e-03], t(313) = -2.00, p = 0.047; Std. beta = -0.09, 95% CI [-0.17, -1.33e-03])
##
## Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using
report(lag_ins_age_TisFrac_int)
## 'interpret_d()' is now deprecated. Please use 'interpret_cohens_d()'.
## 'interpret_d()' is now deprecated. Please use 'interpret_cohens_d()'.
## We fitted a linear mixed model (estimated using ML and nloptwrap optimizer) to predict Ins_conc_molal with mri_age_y and TissueFraction_GMWM (formula: Ins_conc_molal ~ mri_age_y * TissueFraction_GMWM). The model included subj_id as random effect (formula: ~1 | subj_id). The model's total explanatory power is moderate (conditional R2 = 0.17) and the part related to the fixed effects alone (marginal R2) is of 0.05. The model's intercept, corresponding to mri_age_y = 0 and TissueFraction_GMWM = 0, is at 1.96 (95% CI [-0.45, 4.38], t(312) = 1.60, p = 0.111). Within this model:
##
## - The effect of mri age y is statistically significant and positive (beta = 0.47, 95% CI [0.14, 0.80], t(312) = 2.77, p = 0.006; Std. beta = 0.05, 95% CI [-0.07, 0.18])
## - The effect of TissueFraction GMWM is statistically significant and positive (beta = 6.51, 95% CI [2.75, 10.26], t(312) = 3.41, p < .001; Std. beta = 0.22, 95% CI [0.10, 0.34])
## - The interaction effect of TissueFraction GMWM on mri age y is statistically significant and negative (beta = -0.68, 95% CI [-1.22, -0.13], t(312) = -2.45, p = 0.015; Std. beta = -0.12, 95% CI [-0.21, -0.02])
##
## Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using
##Plot results of models including tissue fraction Estimate metabolite residuals using remef Include individual slopes (estimated via linear models by subject) using geom_smooth() Include overall fit line using geom_abline
#LAG - NAA
#pull fixed effects for overall model
fixef.lag_naa_TisFrac<-fixef(lag_naa_age_TisFrac)
#subset dataframe with only subjects included in NAA analysis
lag_dat_plot<- lag_dat %>%
filter(! is.na(NAA_conc_molal))
#calculate partial effect of age on tNAA (remove effect of tissue fraction)
lag_naa_partial <- remef(lag_naa_age_TisFrac, fix = "TissueFraction_GMWM") #does NOT remove random effects variance
#create plot to show NAA ~ age while controlling for Tissue Fraction
plot_lag_naa_age_tf<-ggplot(lag_dat_plot, aes(x=mri_age_y, y=lag_naa_partial, na.exclude = TRUE, color=as.factor(female))) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, aes(x=mri_age_y, y=lag_naa_partial, group=as.factor(subj_id)), size = .3, show.legend = FALSE) +
labs(title = "Left Temporo-Parietal", x = "Age (years)", y = "tNAA | Tissue Fraction") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_abline(aes(intercept = fixef.lag_naa_TisFrac[[1]], slope = fixef.lag_naa_TisFrac[[2]])) +
theme_classic()
plot_lag_naa_age_tf
## `geom_smooth()` using formula 'y ~ x'
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/lag_naa_age_partialef.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
#LAG - Cre
#pull fixed effects for overall model
fixef.lag_cre_age_TisFrac<-fixef(lag_cre_age_TisFrac)
#subset dataframe with only subjects included in NAA analysis
lag_dat_plot_Cre<- lag_dat %>%
filter(! is.na(Cre_PCr_conc_molal))
#calculate partial effect of age on Cre (remove effect of tissue fraction)
lag_cre_partial <- remef(lag_cre_age_TisFrac, fix = "TissueFraction_GMWM") #does NOT remove random effects variance
plot_lag_cre_age_tf<-ggplot(lag_dat_plot_Cre, aes(x=mri_age_y, y=lag_cre_partial, na.exclude = TRUE, color=as.factor(female))) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, aes(x=mri_age_y, y=lag_cre_partial, group=as.factor(subj_id)), size = .3, show.legend = FALSE) +
labs(title = "Left Temporo-Parietal", x = "Age (years)", y = "tCre | Tissue Fraction") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_abline(aes(intercept = fixef.lag_cre_age_TisFrac[[1]], slope = fixef.lag_cre_age_TisFrac[[2]])) +
theme_classic()
plot_lag_cre_age_tf
## `geom_smooth()` using formula 'y ~ x'
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/lag_cre_age_partialef.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
#LAG - Cho
Cho_age_tf_int_plot <- interact_plot(lag_cho_age_TisFrac_int, pred = mri_age_y, modx = TissueFraction_GMWM, data=lag_dat, plot.points=TRUE, legend.main="Tissue Fraction GM/(GM+WM)", modx.labels=c(".535 (-1 SD)", ".642 (Mean)", ".750 (+1 SD)")) +
labs(title = "Left Temporo-Parietal", x = "Age (years)", y = "tCho (molal)") +
scale_color_viridis(option="mako", name="Tissue Fraction GM/(GM+WM)", begin= .32, end=.85) +
theme_classic()
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
Cho_age_tf_int_plot
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/lag_cho_age_tf_int.png")
## Saving 7 x 5 in image
#LAG - Ins
#Main effect of age
#pull fixed effects for overall model
fixef.lag_ins_age_TisFrac_int<-fixef(lag_ins_age_TisFrac_int)
#subset dataframe with only subjects included in NAA analysis
lag_dat_plot_Ins<- lag_dat %>%
filter(! is.na(Ins_conc_molal))
#calculate partial effect of age on Ins (remove effect of tissue fraction)
lag_ins_partial <- remef(lag_ins_age_TisFrac_int, fix = c("TissueFraction_GMWM","mri_age_y:TissueFraction_GMWM")) #does NOT remove random effects variance
#plot main effect of age controlling for tissue fraction and age x tissue fraction interaction
plot_lag_ins_age_tf<-ggplot(lag_dat_plot_Ins, aes(x=mri_age_y, y=lag_ins_partial, na.exclude = TRUE, color=as.factor(female))) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, aes(x=mri_age_y, y=lag_ins_partial, group=as.factor(subj_id)), size = .3, show.legend = FALSE) +
labs(title = "Left Temporo-Parietal", x = "Age (years)", y = "Ins | Tissue Fraction and Tissue Fraction:Age") +
scale_color_viridis(name = "Sex", labels = c("Male", "Female"), discrete = TRUE, option = "H", begin = .2, end = .8) +
geom_abline(aes(intercept = fixef.lag_ins_age_TisFrac_int[[1]], slope = fixef.lag_ins_age_TisFrac_int[[2]])) +
theme_classic()
plot_lag_ins_age_tf
## `geom_smooth()` using formula 'y ~ x'
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/lag_ins_age_tf_maineffect.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
#age x tissue fraction interaction plot
Ins_age_tf_int_plot <- interact_plot(lag_ins_age_TisFrac_int, pred = mri_age_y, modx = TissueFraction_GMWM, data=lag_dat, plot.points=TRUE, legend.main="Tissue Fraction GM/(GM+WM)", modx.labels=c(".535 (-1 SD)", ".642 (Mean)", ".750 (+1 SD)")) +
labs(title = "Left Temporo-Parietal", x = "Age (years)", y = "Ins (molal)") +
scale_color_viridis(option="mako", name="Tissue Fraction GM/(GM+WM)", begin= .32, end=.85) +
theme_classic()
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
Ins_age_tf_int_plot #only the slope for the lowest range of tissue fraction values (-1 SD) is significant
## Warning: Removed 1 rows containing missing values (geom_point).
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/lag_ins_age_tf_int.png")
## Saving 7 x 5 in image
## Warning: Removed 1 rows containing missing values (geom_point).
##Edit plots for manuscript rescale plots to consistent scale, adjust legends, remove individual titles, join plots as panels in figures *Run tissue fractions models and “Plot results of models including tissue fraction” chunks before running this chunk
#ACG plots - main effects only
ACG_NAA<-plot_acg_naa_age +
scale_x_continuous(limits=c(2,8), breaks=seq(2,8,1)) +
scale_y_continuous(limits=c(1,19), breaks=seq(1,19,1)) +
theme(legend.position='none') +
labs(title=NULL)
ACG_NAA
## `geom_smooth()` using formula 'y ~ x'
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/acg_naa_age_n112_rescale.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
ACG_Cho<-plot_acg_cho_age +
scale_x_continuous(limits=c(2,8), breaks=seq(2,8,1)) +
scale_y_continuous(limits=c(1,19), breaks=seq(1,19,1)) +
theme(legend.position='none') +
labs(title=NULL)
ACG_Cho
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/acg_cho_age_n112_rescale.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
ACG_Ins<-plot_acg_ins_age +
scale_x_continuous(limits=c(2,8), breaks=seq(2,8,1)) +
scale_y_continuous(limits=c(1,19), breaks=seq(1,19,1)) +
theme(legend.position=c(.8,.9), legend.background = element_rect(fill="transparent", linetype = NULL)) +
labs(title=NULL)
ACG_Ins
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/acg_ins_age_n112_rescale.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
#Join ACG main effects plots in a single figure
library(patchwork)
ACG_fig<-ACG_NAA + ACG_Cho + ACG_Ins + plot_layout(nrow=1) + plot_annotation(title = 'Relationships between age and metabolite concentrations in anterior cingulate cortex')
ACG_fig
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/ACG_maineffects_fig_grid_viridis.png", ACG_fig, width = 3000, height = 1500, units = "px")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
#read data LAG
lag_dat<-read.csv("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/data/lag_data_molal_outliers_removed_n319_tissuefraction.csv")
#LAG - NAA
#Main effect plots for LAG
#rescale plot to show NAA ~ age while controlling for Tissue Fraction
LAG_NAA<-plot_lag_naa_age_tf +
scale_x_continuous(limits=c(2,12), breaks=seq(2,12,1)) +
scale_y_continuous(limits=c(1,18), breaks=seq(1,18,1)) +
theme(legend.position='none') +
labs(title=NULL)
LAG_NAA
## `geom_smooth()` using formula 'y ~ x'
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/lag_naa_age_partialef_rescale.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
#LAG - Cre
LAG_Cre<-plot_lag_cre_age_tf +
scale_x_continuous(limits=c(2,12), breaks=seq(2,12,1)) +
scale_y_continuous(limits=c(1,18), breaks=seq(1,18,1)) +
theme(legend.position='none') +
labs(title=NULL)
LAG_Cre
## `geom_smooth()` using formula 'y ~ x'
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/lag_cre_age_partialef_rescale.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
#LAG - Ins Main effect of age
LAG_Ins_main<-plot_lag_ins_age_tf +
scale_x_continuous(limits=c(2,12), breaks=seq(2,12,1)) +
scale_y_continuous(limits=c(1,18), breaks=seq(1,18,1)) +
theme(legend.position=c(.8,.9), legend.background = element_rect(fill="transparent", linetype = NULL)) +
labs(title=NULL)
LAG_Ins_main
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/lag_ins_age_tf_maineffect_rescale.png")
## Saving 7 x 5 in image
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
#Join LAG main effects plots in a single figure
library(patchwork)
LAG_fig<-LAG_NAA + LAG_Cre + LAG_Ins_main + plot_layout(nrow=1) + plot_annotation(title = 'Relationships between age and metabolite concentrations in left temporo-parietal region')
LAG_fig
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/LAG_maineffects_fig_grid_viridis.png", LAG_fig, width = 3000, height = 1500, units = "px")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
#interaction plots
#LAG - Cho
LAG_Cho_int<-Cho_age_tf_int_plot +
scale_x_continuous(limits=c(2,12), breaks=seq(2,12,1)) +
scale_y_continuous(limits=c(0,4), breaks=seq(1,4,1)) +
labs(title=NULL)
LAG_Cho_int
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/lag_cho_age_tf_int_rescale.png")
## Saving 7 x 5 in image
#LAG - Ins age x tissue fraction interaction plot
#how to indicate in plot that only the -1 SD line is significant?
LAG_Ins_int<-Ins_age_tf_int_plot +
scale_x_continuous(limits=c(2,12), breaks=seq(2,12,1)) +
scale_y_continuous(limits=c(0,12), breaks=seq(1,12,1)) +
labs(title=NULL)
LAG_Ins_int
## Warning: Removed 1 rows containing missing values (geom_point).
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/lag_ins_age_tf_int_rescale.png")
## Saving 7 x 5 in image
## Warning: Removed 1 rows containing missing values (geom_point).
#Join interaction plots into a single figure
LAG_int_fig<- LAG_Cho_int + LAG_Ins_int + plot_layout(nrow=1, guides = 'collect') + plot_annotation(title='Age x tissue fraction interactions in left temporo-parietal region')
LAG_int_fig
## Warning: Removed 1 rows containing missing values (geom_point).
ggsave("/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/LAG_interactions_fig_grid_viridis.png", LAG_int_fig, width = 3000, height = 1500, units = "px")
## Warning: Removed 1 rows containing missing values (geom_point).
##FDR Correction for multiple comparisons: final models run FDR correction (Benjamini & Hochberg method) on final models (simple growth models for ACG, tissue fraction models for LAG) Following Reynolds et al. 2019 NeuroImage - correct for multiple comparisons within a given factor (e.g. age) across models (2 regions x 5 metabolites = 10 comparisons)
library(broom)
#list models (voxel/metabolite pair)
models<- c("acg_naa_age", "acg_cre_age", "acg_cho_age", "acg_ins_age", "acg_glx_age", "lag_naa_age_TisFrac", "lag_cre_age_TisFrac", "lag_cho_age_TisFrac_int", "lag_ins_age_TisFrac_int", "lag_glx_age_TisFrac_quad")
#list p-values for age in each model, matching order of models (tried to do this with sapply function but couldn't get it to work)
p_age<-c(coef(summary(acg_naa_age))[2,5], coef(summary(acg_cre_age))[2,5], coef(summary(acg_cho_age))[2,5], coef(summary(acg_ins_age))[2,5], coef(summary(acg_glx_age))[2,5], coef(summary(lag_naa_age_TisFrac))[2,5], coef(summary(lag_cre_age_TisFrac))[2,5], coef(summary(lag_cho_age_TisFrac_int))[2,5], coef(summary(lag_ins_age_TisFrac_int))[2,5], coef(summary(lag_glx_age_TisFrac_quad))[2,5])
fdr_table<-data.frame(models, p_age)
fdr_table$p_fdr<-p.adjust(p_age, method = "fdr", n= length(p_age))
fdr_table
## models p_age p_fdr
## 1 acg_naa_age 3.524700e-02 7.049400e-02
## 2 acg_cre_age 5.127407e-01 5.127407e-01
## 3 acg_cho_age 1.566592e-02 5.221975e-02
## 4 acg_ins_age 6.498291e-02 1.083049e-01
## 5 acg_glx_age 2.568733e-01 3.669619e-01
## 6 lag_naa_age_TisFrac 1.840981e-08 1.840981e-07
## 7 lag_cre_age_TisFrac 2.469515e-02 6.173789e-02
## 8 lag_cho_age_TisFrac_int 4.257455e-01 5.124240e-01
## 9 lag_ins_age_TisFrac_int 5.986987e-03 2.993493e-02
## 10 lag_glx_age_TisFrac_quad 4.611816e-01 5.124240e-01
write.csv(fdr_table, "/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/fdr_table_age.csv")
#run FDR correction on 3 models that included interactions (LAG: Cho, Ins, Glx)
models_b<-c("lag_cho_age_TisFrac_int", "lag_ins_age_TisFrac_int", "lag_glx_age_TisFrac_quad")
p_int<-c(coef(summary(lag_cho_age_TisFrac_int))[4,5], coef(summary(lag_ins_age_TisFrac_int))[4,5], coef(summary(lag_glx_age_TisFrac_quad))[5,5])
fdr_table_b<-data.frame(models_b, p_int)
fdr_table_b$p_fdr<-p.adjust(p_int, method = "fdr", n= length(p_int))
fdr_table_b
## models_b p_int p_fdr
## 1 lag_cho_age_TisFrac_int 0.04663834 0.06995751
## 2 lag_ins_age_TisFrac_int 0.01479358 0.04438074
## 3 lag_glx_age_TisFrac_quad 0.32141815 0.32141815
write.csv(fdr_table_b, "/Users/meaghan/OneDrive - University of Calgary/Preschool_data/MRS/results/fdr_table_int.csv")